#include <bits/stdc++.h>
using namespace std;
struct street {
  int t;
  int x, y;
} Node[(int)(1e6 + 10)];
int r, n;
int dis(street u, street v) { return abs(u.x - v.x) + abs(u.y - v.y); }
bool judge(street u, street v) { return abs(u.t - v.t) >= dis(u, v); }
int ans[(int)(1e6 + 10)];
int main() {
  ios::sync_with_stdio(0);
  cin >> r >> n;
  for (int i = 1; i <= n; i++) cin >> Node[i].t >> Node[i].x >> Node[i].y;
  Node[0] = {0, 1, 1};
  for (int i = 1; i <= 2 * r; i++) {
    if (!judge(Node[i], Node[0])) {
      ans[i] = -INT_MAX;
      continue;
    }
    for (int j = 0; j < i; j++) {
      if (judge(Node[i], Node[j])) ans[i] = max(ans[i], ans[j] + 1);
    }
  }
  int suffer_max = 0;
  for (int i = 2 * r + 1; i <= n; i++) {
    if (!judge(Node[i], Node[0])) {
      ans[i] = -INT_MAX;
      continue;
    }
    suffer_max = max(suffer_max, ans[i - 2 * r]);
    ans[i] = max(ans[i], suffer_max + 1);
    for (int j = i - 2 * r + 1; j < i; j++)
      if (judge(Node[i], Node[j])) ans[i] = max(ans[i], ans[j] + 1);
  }
  int maxx = 0;
  for (int i = 1; i <= n; i++) maxx = max(maxx, ans[i]);
  cout << maxx << endl;
}
