#include <bits/stdc++.h>
using namespace std;
bool mysort(pair<int, int> &a, pair<int, int> &b) {
  if (a.first < b.first)
    return 1;
  else if (a.first == b.first && a.second > b.second)
    return 1;
  else
    return 0;
}
int main() {
  int n, i, x, y, coun, pre, cur;
  cin >> n;
  vector<pair<int, int> > a;
  for (i = 0; i < n; i++) scanf(" %d%d", &x, &y), a.push_back({x, y});
  sort(a.begin(), a.end(), mysort);
  if (n == 1) return cout << 0 << endl, 0;
  pre = a[0].second;
  cur = -1;
  coun = 0;
  i = 1;
  while (i < n) {
    if (a[i].first == a[i - 1].first)
      i++;
    else
      break;
  }
  for (; i < n; i++) {
    if (a[i].first != a[i - 1].first) {
      if (cur > pre) pre = cur;
      cur = a[i].second;
    }
    if (a[i].second < pre) coun++;
  }
  cout << coun << endl;
  return 0;
}
