#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int dp[N];
int pdp[2 * N];
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int c, n;
  cin >> c >> n;
  ++n;
  pair<pair<int, int>, int> a[n];
  a[0] = {{1, 1}, 0};
  for (int i = 1; i < n; i++)
    cin >> a[i].second >> a[i].first.first >> a[i].first.second;
  memset(dp, 0, sizeof dp);
  memset(pdp, 0, sizeof pdp);
  dp[n - 1] = 1;
  pdp[n - 1] = 1;
  for (int i = n - 2; i >= 0; i--) {
    dp[i] = i != 0;
    for (int j = i + 1; j < min(n, i + 1005); j++) {
      int taken = abs(a[i].first.first - a[j].first.first) +
                  abs(a[i].first.second - a[j].first.second);
      int can = a[j].second - a[i].second;
      if (taken <= can) {
        dp[i] = max(dp[i], dp[j] + (i != 0));
      }
    }
    dp[i] = max(dp[i], pdp[i + 1004] + (i != 0));
    pdp[i] = max(dp[i], pdp[i + 1]);
  }
  cout << dp[0] << endl;
}
