#include <bits/stdc++.h>
using namespace std;
vector<pair<long long int, long long int> > h;
int main() {
  long long int n;
  cin >> n;
  long long int a, b;
  for (long long int i = 0; i < ((long long int)(n)); i++) {
    cin >> a >> b;
    h.push_back(make_pair(a, b));
  }
  sort((h).begin(), (h).end());
  long long int ma = h[0].second;
  long long int res = 0;
  for (long long int i = (long long int)(1); i < ((long long int)(n)); i++) {
    if (h[i].second < ma)
      res++;
    else
      ma = h[i].second;
  }
  cout << res << endl;
  return 0;
}
