#include <bits/stdc++.h>
#pragma GCC optimize(3)
using namespace std;
using std::bitset;
const double Pi = acos(-1);
inline int read() {
  int x = 0;
  bool fu = 0;
  char ch = 0;
  while (ch > '9' || ch < '0') {
    ch = getchar();
    if (ch == '-') fu = 1;
  }
  while (ch <= '9' && ch >= '0') x = (x * 10 - 48 + ch), ch = getchar();
  return fu ? -x : x;
}
inline char readc() {
  register char c;
  while ((c = getchar()) == ' ' || c == '\n')
    ;
  return c;
}
int dp[100002], n, r, t[100002], a[100002], b[100002], mmax[100002], ans;
int main() {
  memset(dp, -0x3f, sizeof(dp));
  dp[0] = 0;
  cin >> r >> n;
  a[0] = b[0] = 1;
  for (register int i = 1, iend = n; i <= iend; ++i) {
    t[i] = read(), a[i] = read(), b[i] = read();
    if (i >= 1000) dp[i] = mmax[i - 1000] + 1;
    for (register int j = max(0, i - 1000), jend = i - 1; j <= jend; ++j) {
      if (abs(a[i] - a[j]) + abs(b[i] - b[j]) + t[j] <= t[i])
        dp[i] = max(dp[i], dp[j] + 1);
    }
    mmax[i] = max(mmax[i - 1], dp[i]);
    ans = max(ans, dp[i]);
  }
  cout << ans;
  return 0;
}
