program elysian;
type
node=record
b,e:longint;
end;
const
fin='a.txt';fout='punch.out';
var
f1,f2:text;
f:array[1..10010] of boolean;
a:array[1..10010] of node;
n,ans:longint;
procedure init;
var
i,j:longint;
begin
assign(f1,fin);reset(f1);
readln(f1,n);
fillchar(f,sizeof(f),false);
for i:=1 to n do
begin
inc(ans);
readln(f1,a[i].b,a[i].e);
for j:=1 to i-1 do
if f[j]=false then
begin
if (a[j].b>=a[i].b)and(a[j].b<=a[i].e)and(a[j].e<=a[i].e)and(a[j].e>=a[i].b) then
begin
f[j]:=true;
dec(ans);
end;
if (a[i].b>=a[j].b)and(a[i].b<=a[j].e)and(a[i].e>=a[j].e) then
a[j].e:=a[i].b;
if (a[i].b<=a[j].b)and(a[i].e<=a[j].e)and(a[i].e>=a[j].b) then
a[j].b:=a[i].e;
end;
end;
assign(f2,fout);rewrite(f2);
writeln(f2,ans);
end;
begin
init;
close(f1);
close(f2);
end.