#include <bits/stdc++.h>
using namespace std;
int a[100002], b[100000];
int main() {
  int n;
  cin >> n;
  set<pair<int, int> > c;
  c.clear();
  for (int i = 1; i <= n; i++) {
    int x, y;
    cin >> x >> y;
    pair<int, int> a = make_pair(x, y);
    c.insert(a);
  }
  n = 0;
  set<pair<int, int> >::iterator j;
  for (j = c.begin(); j != c.end(); j++) {
    n++;
    a[n] = (*j).first;
    b[n] = (*j).second;
  }
  int ans = 0, max = -2000000000;
  for (int i = 1; i <= n; i++) {
    if (b[i] < max) ans++;
    if (b[i] > max) max = b[i];
  }
  cout << ans << endl;
  return 0;
}
