#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  vector<pair<int, int> > v;
  int a, b;
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &a, &b);
    v.push_back(make_pair(a, b));
  }
  sort(v.begin(), v.end());
  int ans = 0;
  for (int i = 1; i < n; i++) {
    if (v[i].second < v[i - 1].second) {
      ans++;
      v[i].second = v[i - 1].second;
    }
  }
  printf("%d", ans);
  return 0;
}
