1 //It is made by jump~
2 #include <iostream>
3 #include <cstdlib>
4 #include <cstring>
5 #include <cstdio>
6 #include <cmath>
7 #include <algorithm>
8 #include <ctime>
9 #include <vector>
10 #include <queue>
11 #include <map>
12 #include <set>
13 #ifdef WIN32
14 #define OT "%I64d"
15 #else
16 #define OT "%lld"
17 #endif
18 using namespace std;
19 typedef long long LL;
20 const int MAXM = 10011;
21 int n,m,ans;
22 int f[MAXM];
23
24 struct mouce{
25 int tim,x,y;
26 }a[MAXM];
27
28 inline int getint()
29 {
30 int w=0,q=0;
31 char c=getchar();
32 while((c<‘0‘ || c>‘9‘) && c!=‘-‘) c=getchar();
33 if (c==‘-‘) q=1, c=getchar();
34 while (c>=‘0‘ && c<=‘9‘) w=w*10+c-‘0‘, c=getchar();
35 return q ? -w : w;
36 }
37
38 inline void work(){
39 n=getint(); m=getint();
40 for(int i=1;i<=m;i++) a[i].tim=getint(),a[i].x=getint(),a[i].y=getint(),f[i]=1;
41 for(int i=1;i<=m;i++) {
42 for(int j=i-1;j;j--) {
43 int x=abs(a[j].x-a[i].x)+abs(a[j].y-a[i].y);
44 if(x<=a[i].tim-a[j].tim) f[i]=max(f[j]+1,f[i]);
45 }
46 }
47 for(int i=1;i<=m;i++) if(f[i]>ans) ans=f[i];//不一定是最后一个!!!
48 printf("%d",ans);
49 }
50
51 int main()
52 {
53 work();
54 return 0;
55 }