#include using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(0); int N, ans, mx = -1; cin >> N; ans = N; vector> a(N); for(auto &&[r, R] : a){ cin >> r >> R; swap(r, R); } sort(a.begin(), a.end()); for(auto [R, r] : a){ if (mx <= r){ mx = R; ans--; } } cout << ans << '\n'; }