#include #include using namespace std; using namespace atcoder; typedef long long ll; typedef long double ld; #define sz(c) ((ll)(c).size()) #define ALL(x) x.begin(),x.end() #define rep(i,a,b) for(int i=a;i>n; vector>P(n); int c=-1; rep(i,0,n){ int r,R;cin>>r>>R; P[i]={R,r}; } sort(ALL(P)); int ans=0; rep(i,0,n){ if(c<=P[i].second){ans++;c=P[i].first;} } cout<