#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > p;
int main() {
  int n, a, b;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &a, &b);
    p.push_back(make_pair(a, b));
  }
  sort(p.begin(), p.end());
  int m;
  m = p[0].second;
  int i = 1;
  while (i < n && p[i].first == p[i - 1].first) {
    m = max(m, p[i].second);
    i++;
  }
  int ans = 0;
  int m1;
  while (i < n) {
    m1 = m;
    if (p[i].second < m)
      ans++;
    else
      m1 = p[i].second;
    i++;
    while (i < n && p[i].first == p[i - 1].first) {
      if (p[i].second < m)
        ans++;
      else
        m1 = p[i].second;
      i++;
    }
    m = m1;
  }
  printf("%d\n", ans);
  return 0;
}
