type rec=record
s,e:longint;
end;
var n,i,ans,en:longint;
a:array[0..200000]of rec;
procedure swap(var a,b:rec);
var t:rec;
begin
t:=a; a:=b; b:=t;
end;
procedure qsort(l,r:longint);
var i,j,mide:longint;
begin
i:=l; j:=r;
mide:=a[(l+r)div 2].e;
repeat
while a[i].e<mide do inc(i);
while a[j].e>mide do dec(j);
if i<=j then begin
swap(a[i],a[j]);
inc(i);
dec(j);
end;
until i>j;
if l<j then qsort(l,j);
if i<r then qsort(i,r);
end;
begin
readln(n);
for i:=1 to n do readln(a[i].s,a[i].e);
qsort(1,n);
// for i:=1 to n do writeln(a[i].s,' ',a[i].e);
ans:=1;
en:=a[1].e;
for i:=2 to n do
if a[i].s>en then begin
en:=a[i].e;
inc(ans);
end;
writeln(ans);
close(input);close(output);
end.