#include<bits/stdc++.h>
struct node{
int shi;
int zhong;
};
bool cmp(node a,node b){
if(a.zhong<b.zhong){
return true;
}else{
return false;
}
}
node a[1000050];
int n,cnt=1;
using namespace std;
int main(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i].shi>>a[i].zhong;
}
sort(a+1,a+1+n,cmp);
int k=a[1].zhong;
for(int i=2;i<=n;i++){
if(a[i].shi>=k){
cnt++;
k=a[i].zhong;
}
}
cout<<cnt;
return 0;
}