#include <bits/stdc++.h> using namespace std; int main() { int n; cin>>n; int l[n],r[n]; for(int i = 0;i<n;i++) cin>>l[i]>>r[i]; for(int i = 0;i<n-1;i++){//右邊界排序 int temp; for(int j = i+1;j<n;j++){ if(r[i]>r[j]){ temp = r[i]; r[i] = r[j]; r[j] = temp; temp = l[i]; l[i] = l[j]; l[j] = temp; } } } int count = 1; int p = r[0]; for(int i = 1;i<n;i++){ int flag = 0; if(p<l[i]){ count++; p = r[i]; } } cout<<count; return 0; }