#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  vector<pair<int, int> > vec(n);
  for (int i = 0; n > i; i++) {
    cin >> vec[i].first >> vec[i].second;
  }
  sort(vec.begin(), vec.end());
  int son = vec[0].second, say = 0;
  for (int i = 0; n > i; i++) {
    if (son > vec[i].second) {
      say++;
      continue;
    }
    son = vec[i].second;
  }
  cout << say;
}
