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