#include <bits/stdc++.h>
using namespace std;
struct node {
  int t, x, y;
};
node a[100005];
int dp[100005];
int n, r;
int main() {
  scanf("%d%d", &r, &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d", &a[i].t, &a[i].x, &a[i].y);
  }
  a[0].x = a[0].y = 1, a[0].t = 0;
  for (int i = 1; i <= n; i++) {
    if (abs(a[0].x - a[i].x) + abs(a[0].y - a[i].y) <= a[i].t - a[0].t) {
      dp[i] = 1;
    }
  }
  for (int i = 2; i <= n; i++) {
    for (int j = max(0, i - 1 - 4 * r); j <= i - 1; j++) {
      if (dp[j] != 0 &&
          abs(a[j].x - a[i].x) + abs(a[j].y - a[i].y) <= a[i].t - a[j].t) {
        dp[i] = max(dp[i], dp[j] + 1);
      }
    }
  }
  sort(dp + 1, dp + 1 + n);
  printf("%d", dp[n]);
  return 0;
}
