#include using namespace std; typedef long long ll; const int INF = 1<<30; const long long INFLL = 1LL<<60; const int MOD = 998244343; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll n; cin >> n; vector> Rr(n, vector(2)); for (int i = 0; i < n; i++){ ll r, R; cin >> r >> R; Rr[i][0] = R; Rr[i][1] = r; } sort(Rr.begin(), Rr.end()); ll pre_R = 0; ll cnt = 0; for (int i=0; i < n; i++){ if (Rr[i][1] >= pre_R){ pre_R = Rr[i][0]; cnt++; } } cout << n - cnt << endl; }