var
l,m,i,j,k,b,n:integer;
a:array[0..10000] of boolean;
begin
assign(input,'tsuri.in');
assign(output,'tsuri.out');
reset(input);
rewrite(output);
fillchar(a,sizeof(a),false);
i:=0;
readln(l,m);
for m:=1 to m do
begin
readln(j,k);
for b:=j to k do a[b]:=true;
end;
for n:=0 to l do
if a[n]=false then inc(i);
write(i);
close(input);
close(output);
end.