program waterfire;
const
fin='punch.in';
fout='punch.out';
type
ok=record
x,y:longint;
end;
var
i,j,n,color:longint;
data:array[0..10000] of ok;
f1,f2:text;
BEGIN
assign(f1,fin);reset(f1);
assign(f2,fout);rewrite(f2);
readln(f1,n);
color:=0;
readln(f1,data[1].x,data[1].y);
for i:=2 to n do
begin
readln(f1,data[i].x,data[i].y);
for j:=1 to i-1 do
begin
if (data[i].x<=data[j].x)and(data[i].y>=data[j].y) then
begin
data[j].x:=0;
data[j].y:=0;
end;
if (data[i].y>data[j].y)and(data[i].x>data[j].x)and(data[i].x<data[j].y) then data[j].y:=data[i].x;
if (data[i].x<data[j].x)and(data[i].y<data[j].y)and(data[i].y>data[j].x) then data[j].x:=data[i].y;
end;
end;
for i:=1 to n do
if not((data[i].x=0)and(data[i].y=0)) then inc(color);
writeln(f2,color);
close(f1);close(f2);
END.