https://www.luogu.com.cn/problem/P1803
include
include
include
using namespace std;
vector<pair<int,int> > vct;
int main(){
int n;
scanf("%d", &n);
for(int i=1; i<=n; i++){
int a, b;
scanf("%d %d", &a, &b) ;
vct.push_back(make_pair(a, b)) ;}
sort(vct.begin(), vct.end()) ;
int sum = 0 ;
for(int i=0; i<(int)vct.size(); i++){
if(i<n-1 && vct[i+1].first < vct[i].second) vct[i+1].second = min(vct[i+1].second, vct[i].second) ;
else sum ++ ;
}
printf("%d", sum) ;
return 0;}