#include <bits/stdc++.h>
using namespace std;
pair<int, int> a[100000];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i].first >> a[i].second;
  sort(a, a + n);
  int m = 0, r = 0;
  for (int i = 0; i < n; i++) {
    if (a[i].second <= m) r++;
    m = max(m, a[i].second);
  }
  cout << r;
  return 0;
}
