#include <bits/stdc++.h>
using namespace std;
int n, ans = 0;
pair<int, int> a[100005];
int ax[100005];
const int INF = 2e9 + 3;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i].first >> a[i].second;
  sort(a, a + n);
  int mk = 0, last = -1;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (a[mk] != a[i]) {
      if (a[i].second < last) ans++;
    }
    if (i != n - 1 && a[i] != a[i + 1]) {
      mk = i;
      last = max(last, a[i].second);
    }
  }
  cout << ans;
  return 0;
}
