#include <bits/stdc++.h>
using namespace std;
struct triple {
  int time, first, second;
  triple(int a = 0, int b = 0, int c = 0) { time = a, first = b, second = c; }
};
triple man[100005];
int dp[100005], pref[100005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int r, n;
  cin >> r >> n;
  for (int i = 1; i <= n; i++)
    cin >> man[i].time >> man[i].first >> man[i].second;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (man[i].first + man[i].second - 2 > man[i].time)
      dp[i] = 0;
    else {
      dp[i] = 1;
      for (int j = i - 1; j >= max(1, i - 1000); j--)
        if (abs(man[j].first - man[i].first) +
                abs(man[j].second - man[i].second) <=
            man[i].time - man[j].time)
          dp[i] = max(dp[i], dp[j] + 1);
      if (i > 1000) dp[i] = max(dp[i], pref[i - 1000] + 1);
    }
    pref[i] = max(pref[i - 1], dp[i]);
    ans = max(ans, dp[i]);
  }
  cout << ans << '\n';
  return 0;
}
