#include <bits/stdc++.h>
using namespace std;
const int mxN = 1e5, mxR = 500;
int n, r, a[mxN + 10][3], dp[mxN + 10];
set<array<int, 2> > values;
bool moze(int i, int j) {
  if (abs(a[j][1] - a[i][1]) + abs(a[j][2] - a[i][2]) <= a[j][0] - a[i][0])
    return true;
  return false;
}
int f(int ind) {
  for (auto x : values) {
    int i = -x[1];
    if (moze(i, ind)) return i;
  }
  return -1;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> r >> n;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    int t, x, y;
    cin >> t >> x >> y;
    if (t >= x + y - 2) {
      a[cnt][0] = t;
      a[cnt][1] = x;
      a[cnt][2] = y;
      cnt++;
    }
  }
  n = cnt;
  dp[0] = 1;
  values.insert({-1, 0});
  for (int i = 1; i < n; i++) {
    int ind = f(i);
    if (~ind)
      dp[i] = dp[ind] + 1;
    else
      dp[i] = 1;
    values.insert({-dp[i], -i});
  }
  int ans = 0;
  for (int i = 0; i < n; i++) ans = max(ans, dp[i]);
  cout << ans << '\n';
  return 0;
}
