var n,m,i,j,ans:longint; x,y,time,f:array[0..10010]of longint; begin readln(n,m); for i:=1 to m do readln(time[i],x[i],y[i]); ans:=1; for i:=1 to m do begin f[i]:=1; for j:=1 to i-1 do if (time[i]-time[j]>=abs(x[i]-x[j])+abs(y[i]-y[j])) and (f[i]<f[j]+1) then begin f[i]:=f[j]+1; if f[i]>ans then ans:=f[i]; end; end; writeln(ans); end.