#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  pair<int, int> A[n];
  for (int i = 0; i < n; i++) cin >> A[i].first >> A[i].second;
  sort(A, A + n);
  int count = 0;
  int X = A[0].second;
  for (int i = 1; i < n; i++)
    if (X > A[i].second)
      count++;
    else
      X = A[i].second;
  cout << count;
  return 0;
}
