var
ans,l,m,i,j:longint;
a,b:array[1..100] of longint;
function max(x,y:longint):longint;
begin
if x>y then exit(x)
else exit(y);
end;
function min(x,y:longint):longint;
begin
if x<y then exit(x)
else exit(y);
end;
begin
readln(l,m);
ans:=0;
for i:=1 to m do
readln(a[i],b[i]);
for i:=1 to m do
for j:=1 to m do
if((a[i]>a[j])and(a[i]<b[j]))or((a[j]>a[i])and(a[j]<b[i])) then
begin
a[i]:=min(a[i],a[j]);
b[i]:=max(b[i],b[j]);
a[j]:=0;
b[j]:=0;
end;
for i:=1 to m do
if b[i]>0 then ans:=ans+b[i]-a[i]+1;
write(l+1-ans);
end.