program ds;
var
a,b:array[0..1000] of longint;
color:array[0..1000] of boolean;
data:array[0..100000] of longint;
f:text;
m,i,j,k,n:longint;
begin
assign(f,'punch.in');
reset(f);
readln(f,n); m:=0;
for i:=1 to n do begin
readln(f,j,k); a[i]:=j; b[i]:=k;
if b[i]>m then m:=b[i];
end;
fillchar(data,sizeof(data),0);
fillchar(color,sizeof(color),true);
for i:=1 to n do begin
for j:=a[i] to b[i] do
data[j]:=i;
end;
for i:=1 to m do
color[data[i]]:=false;
k:=0;
for i:=1 to n do
if color[i]=false then k:=k+1;
assign(f,'punch.out');
rewrite(f);
writeln(f,k);
close(f);
end.