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