#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1.0);
const int BLOCK = 333;
int dp[1010101], pref[1010101];
int t[1010101], x[1010101], y[1010101], N, R;
int dist(int i, int j) { return abs(x[i] - x[j]) + abs(y[i] - y[j]); }
int MAGIC = 1010;
int main(int argc, char const *argv[]) {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> R >> N;
  for (int i = 1; i <= N; i++) dp[i] = -2000000020LL;
  x[0] = y[0] = 1;
  for (int i = 1; i <= N; i++) cin >> t[i] >> x[i] >> y[i];
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= i && j <= MAGIC; j++) {
      if (dist(i, i - j) <= t[i] - t[i - j]) dp[i] = max(dp[i], 1 + dp[i - j]);
      if (j == MAGIC) dp[i] = max(dp[i], pref[i - j] + 1);
    }
    pref[i] = max(dp[i], pref[i - 1]);
  }
  cout << pref[N] << '\n';
  return 0;
}
