#include <bits/stdc++.h>
using namespace std;
int oo = 1000000000;
int n, r;
pair<int, pair<int, int> > a[100005];
int dp[100005];
int pre[100005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);
  cin >> r >> n;
  a[1] = {0, {1, 1}};
  n++;
  for (int i = 2; i <= n; i++) {
    int t, x, y;
    cin >> t >> x >> y;
    a[i] = {t, {x, y}};
  }
  for (int k = 2; k <= n; k++) {
    int i = k - 1;
    dp[k] = -oo;
    while (i >= max(1, k - 2 * r + 1)) {
      int dx = abs(a[k].second.first - a[i].second.first);
      int dy = abs(a[k].second.second - a[i].second.second);
      int dt = a[k].first - a[i].first;
      if (dt >= dx + dy && dp[i] >= 0) dp[k] = max(dp[k], dp[i] + 1);
      i--;
    }
    if (k - 2 * r >= 1) dp[k] = max(dp[k], pre[k - 2 * r] + 1);
    pre[k] = max(dp[k], pre[k - 1]);
  }
  cout << pre[n] << endl;
  return 0;
}
