#include <bits/stdc++.h>
using namespace std;
void solve() {
  int R, N;
  cin >> R >> N;
  vector<int> time(N), x(N), y(N);
  for (int i = 0; i < N; i++) {
    cin >> time[i] >> x[i] >> y[i];
  }
  vector<int> dp(N);
  vector<int> best(N);
  for (int i = 0; i < N; i++) {
    if (time[i] >= abs(x[i] - 1) + abs(y[i] - 1)) dp[i] = 1;
    for (int j = i - 1; j >= 0; j--) {
      int time_diff = time[i] - time[j];
      int dist_diff = abs(x[j] - x[i]) + abs(y[j] - y[i]);
      if (dp[j]) {
        if (time_diff >= dist_diff) {
          dp[i] = max(dp[i], dp[j] + 1);
        }
      }
      if (time_diff >= 2 * (R + 1)) {
        dp[i] = max(dp[i], best[j] + 1);
        break;
      }
    }
    if (i != 0)
      best[i] = max(best[i - 1], dp[i]);
    else
      best[i] = dp[i];
  }
  cout << best[N - 1];
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int T;
  T = 1;
  while (T--) {
    solve();
    cout << "\n";
  }
  return 0;
}
