var f:array[1..200100]of boolean;
l,r,n,m,i,j,tot:longint;
begin
assign(input,'axis.in');reset(input);
assign(output,'axis.out');rewrite(output);
read(n,m);
fillchar(f,sizeof(f),true);
for i:=1 to m do
begin
tot:=0;
read(l,r);
for j:=l to r do f[j]:=false;
for j:=1 to n do if f[j] then inc(tot);
writeln(tot);
end;
close(input);close(output);
end.