#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, c = 0;
  cin >> n;
  vector<pair<long long int, long long int>> list(n);
  vector<long long int> ma(n);
  for (long long int i = 0; i < n; i++) cin >> list[i].first >> list[i].second;
  sort(list.begin(), list.end());
  reverse(list.begin(), list.end());
  ma[n - 1] = list[n - 1].second;
  for (long long int i = n - 2; i >= 0; i--)
    ma[i] = max(ma[i + 1], list[i].second);
  for (long long int i = 0; i < n - 1; i++)
    if (list[i].second < ma[i + 1]) c++;
  cout << c;
  return 0;
}
