#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i;
  cin >> n;
  vector<pair<int, int> > v(n);
  for (i = 0; i < n; i = i + 1) {
    cin >> v[i].first >> v[i].second;
  }
  sort(v.begin(), v.end());
  int mx = v[0].second, res = 0;
  for (i = 1; i < n; i = i + 1) {
    if (v[i].second < mx) {
      res++;
    }
    mx = max(mx, v[i].second);
  }
  cout << res << endl;
}
