program cojs1151;
type
node=record
s,f:longint;
end;
var
a:array[0..10000] of node;
i,j,k,m,n:longint;
procedure qp(l,r:longint);
var
i,j:longint;
x,y:node;
begin
i:=l; j:=r;
x:=a[(l+r) div 2];
repeat
while a[i].f<x.f do inc(i);
while a[j].f>x.f do dec(j);
if i<=j then
begin
y:=a[i]; a[i]:=a[j]; a[j]:=y;
inc(i); dec(j);
end;
until i>j;
if j>l then qp(l,j);
if i<r then qp(i,r);
end;
begin
assign(input,'active.in');
assign(output,'active.out');
reset(input);
rewrite(output);
readln(n);
for i:=1 to n do
readln(a[i].s,a[i].f);
qp(1,n);
k:=-1;
m:=0;
for i:=1 to n do
if a[i].s>k then
begin
inc(m);
k:=a[i].f;
end;
writeln(m);
close(input);
close(output);
end.