#include <bits/stdc++.h>
using namespace std;
struct node {
  int x;
  int y;
};
bool compare(struct node a1, struct node a2) {
  if (a1.x < a2.x) return true;
  return false;
}
int main() {
  int n;
  scanf("%d", &n);
  struct node arr[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr[i].x);
    scanf("%d", &arr[i].y);
  }
  sort(arr, arr + n, compare);
  long long ans = 0, temp = 0;
  for (int i = 0; i < n; i++) {
    if (arr[i].y > temp) {
      temp = arr[i].y;
    } else {
      ans++;
    }
  }
  cout << ans << endl;
}
