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