program nike;
Var
p,t,f:array[0..10001]of integer;
n,k,i,j:integer;
begin
assign(input,'lignja.in');reset(input);
assign(output,'lignja.out');rewrite(output);
readln(n,k);
for i:=1 to k do read(p[i],t[i]);
fillchar(f,sizeof(f),0);
j:=k;
for i:=n downto 1 do
if p[j]<>i then f[i]:=f[i+1]+1
else
while p[j]=i do
begin
if f[i]<f[p[j]+t[j]]
then f[i]:=f[p[j]+t[j]];
dec(j);
end;
writeln(f[1]);
close(input); close(output);
end.