#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2")
int32_t main() {
  int n;
  scanf("%d", &n);
  vector<pair<int, int> > a(n);
  for (pair<int, int>& i : a) scanf("%d%d", &i.first, &i.second);
  sort(begin(a), end(a));
  int res = 0, mx = 0;
  for (pair<int, int>& i : a) {
    mx = max(mx, i.second);
    if (mx > i.second) res++;
  }
  cout << res << "\n";
  return 0;
}
