#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int dp[100005];
  vector<int> t;
  vector<pair<int, int> > p;
  int r, n;
  cin >> r >> n;
  t.push_back(0);
  p.push_back(make_pair(1, 1));
  for (int i = 0; i < n; i++) {
    dp[i] = 0;
    int x, y;
    cin >> x;
    t.push_back(x);
    cin >> x >> y;
    p.push_back(make_pair(x, y));
  }
  int maxi = 0, ans = 0;
  dp[n] = 0;
  for (int i = n; i >= 0; i--) {
    for (int j = i - 1; j >= max(0, i - 2000); j--) {
      int dif = abs(p[i].first - p[j].first) + abs(p[i].second - p[j].second);
      if (dif <= abs(t[i] - t[j])) {
        dp[j] = max(dp[j], dp[i] + 1);
      }
    }
  }
  cout << dp[0] << endl;
  return 0;
}
