/*
* * author: attacker
* * created: 24.01.2026 17:57:52
*/
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif
#define mt_rng mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
auto Do = [&](vector<pair<int, bool>>& v, int time) -> void {
int val = 1;
int sz = int(v.size());
for (auto& [zombie, live] : v) {
if (!live) continue;
if (zombie > 0) {
zombie += time;
}
}
int cnt = 0;
for (int i = 0; i < sz && cnt < time; i++) {
auto& [zombie, live] = v[i];
if (zombie == 0 && live) {
zombie = time - cnt;
cnt++;
}
}
};
int n, m, k;
cin >> n >> m >> k;
vector<tuple<int, int, int>> a(k);
for (auto& [x, r, t] : a) {
cin >> x >> r >> t;
}
sort(a.begin(), a.end(), [&](tuple<int, int, int> x, tuple<int, int, int> y) {
return get<2>(x) < get<2>(y);
});
vector<pair<int, bool>> zombies(m, {0, true});
int id = 0;
// debug(a, zombies);
int last = 0;
for (auto& [x, r, t] : a) {
Do(zombies, t - last);
last = t;
for (auto& [zombie, live] : zombies) {
if (!live) continue;
if (zombie > 0 && abs(x - zombie) <= r && zombie <= n) {
live = false;
}
}
}
// debug(zombies);
int ans = 0;
for (auto& [zombie, live] : zombies) {
if (live) {
ans++;
}
}
cout << ans << '\n';
return 0;
}