program punch;
var
i,j,sum,n:integer;
card:array [1..10000] of record
a,b:longint;
end;
begin
assign (input,'punch.in');
reset (input);
readln (n);
for i:=1 to n do readln (card[i].a,card[i].b);
close (input);
assign (output,'punch.out');
rewrite (output);
sum:=n;
for i:=1 to n-1 do for j:=i+1 to n do if (card[j].a<=card[i].a) and (card[j].b>=card[i].b) then dec(sum);
writeln (sum);
close (output);
end.