#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef pair<int ,int> PII;
vector<PII>regs;
int N=100010;
void merge(vector<PII>®s){
vector<PII> ans;
sort(regs.begin(),regs.end());
int l=-2e9,r=-2e9;
for(auto reg:regs){
if(reg.first>r){
if(r!=-2e9)ans.push_back({r,l});
l=reg.first;
r=reg.second;
}else r=max(r,reg.second);
}
if(l!=-2e9)ans.push_back({l,r});
regs=ans;
}
int main(){
int n;
cin>>n;
while(n--){
int x,c;
cin>>x>>c;
regs.push_back({x,c});
}
merge(regs);
cout<<regs.size()<<endl;
return 0;
}