#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int n;
pair<int, int> a[N];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d %d", &a[i].first, &a[i].second);
  }
  sort(a, a + n);
  int maxBest = 0, ans = 0;
  for (int i = 0; i < n;) {
    int j = i;
    for (; j < n && a[j].first == a[i].first; ++j)
      if (a[j].second < maxBest) ans++;
    for (j = i; j < n && a[j].first == a[i].first; ++j)
      maxBest = max(maxBest, a[j].second);
    i = j;
  }
  printf("%d\n", ans);
  return 0;
}
