#include <bits/stdc++.h>
using namespace std;
int main() {
  int r, n;
  cin >> r >> n;
  pair<int, pair<int, int>> p[n];
  for (int i = 0; i < n; i++) {
    cin >> p[i].first >> p[i].second.first >> p[i].second.second;
  }
  int dp[n];
  int mtdp[n];
  memset(dp, 0, sizeof(dp));
  memset(mtdp, 0, sizeof(mtdp));
  if (p[0].second.first + p[0].second.second - 2 <= p[0].first) {
    dp[0] = 1;
    mtdp[0] = 1;
  }
  int result = dp[0];
  for (int i = 1; i < n; i++) {
    int t_now = p[i].first;
    int x = p[i].second.first;
    int y = p[i].second.second;
    if (t_now >= x + y - 2) dp[i] = 1;
    for (int j = max(0, i - 1000); j < i; j++) {
      int t_then = p[j].first;
      int a = p[j].second.first;
      int b = p[j].second.second;
      if (t_now - t_then >= abs(x - a) + abs(y - b)) {
        if (dp[j] > 0) dp[i] = max(dp[i], 1 + dp[j]);
      }
    }
    if (i >= 1000) dp[i] = max(dp[i], mtdp[i - 1000] + 1);
    result = max(result, dp[i]);
    mtdp[i] = max(mtdp[i - 1], dp[i]);
  }
  cout << result << endl;
}
