#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int a[6000],b[6000],i,m,n,j;
int f[6000]={0},jl,sum=0;
bool pd=false;
int main ()
{
freopen("google.in","r",stdin);
freopen("google.out","w",stdout);
cin>>n;
for (i=1;i<=n;++i)
cin>>a[i]>>b[i];
m=1;pd=false;
while (pd==false)
{
j=m;
for (i=1;i<=n;++i)
if (a[i]<=m&&b[i]>=j&&f[i]==0)
{
jl=i;
j=b[i];
}
f[jl]=1;
m=b[jl]+1;
sum+=1;
if (m-1==n) break;
}
cout<<sum;
fclose(stdin);
fclose(stdout);
return 0;
}