#include <bits/stdc++.h>
using namespace std;
struct point {
  int x, y;
} a[100010];
bool comp(point a, point b) {
  if (a.x == b.x) return a.y < b.y;
  return a.x < b.x;
}
int main() {
  int n;
  while (cin >> n) {
    for (int i = 0; i < n; i++) cin >> a[i].x >> a[i].y;
    sort(a, a + n, comp);
    int cnt = 0, mx = 0;
    for (int i = 0; i < n; i++) {
      mx = max(mx, a[i].y);
      if (mx > a[i].y) cnt++;
    }
    cout << cnt << endl;
  }
  return 0;
}
