#include <bits/stdc++.h>
using namespace std;
int digitcount(int n) {
  int result = 0;
  for (int i = n; i > 0; i /= 10) {
    result++;
  }
  return result;
}
int power(int a, int b) {
  if (b == 0) return 1;
  if (b == 1) return a;
  return a * power(a, b - 1);
}
bool pal(string str) {
  for (int i = 0; i < str.size() / 2; i++) {
    if (str[i] != str[str.size() - 1 - i]) return false;
  }
  return true;
}
int main() {
  int n;
  cin >> n;
  pair<int, int> arr[n];
  bool tick[n];
  for (int i = 0; i < n; i++) tick[i] = false;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    arr[i].first = a;
    arr[i].second = b;
  }
  int count = 0;
  sort(arr, arr + n);
  int curMax = -1;
  for (int i = 0; i < n; i++) {
    if (arr[i].second > curMax) {
      curMax = arr[i].second;
      continue;
    }
    count++;
  }
  cout << count << endl;
}
