#include <bits/stdc++.h>
using namespace std;
int n, r, t[100005], x[100005], y[100005], f[100005], Max[100005];
int main() {
  scanf("%d%d", &r, &n);
  for (int i = 1; i <= n; i++) scanf("%d%d%d", &t[i], &x[i], &y[i]);
  for (int i = 1; i <= n; i++) {
    if (abs(x[i] - 1) + abs(y[i] - 1) <= t[i]) f[i] = 1;
    for (register int j = i - 1; j >= 1; j--) {
      if (Max[j] + 1 <= f[i])
        break;
      else if (abs(x[j] - x[i]) + abs(y[j] - y[i]) <= t[i] - t[j] && f[j])
        f[i] = max(f[i], f[j] + 1);
      else
        continue;
    }
    Max[i] = max(Max[i - 1], f[i]);
  }
  printf("%d\n", Max[n]);
}
