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