#include using namespace std; #define REP(i, n) for(int i=0 ; (i)<(int)(n) ; (i)++) int main(void){ int n; cin >> n; vector> rr(n); REP(i, n) cin >> rr.at(i).first >> rr.at(i).second; sort(rr.begin(), rr.end()); int ans = 0, tmp = 0; for(auto i : rr){ if(tmp > i.first){ ans++; continue; } tmp = i.second; } cout << ans << endl; }