#include <bits/stdc++.h>
template <class T>
inline T sqr(T x) {
  return x * x;
}
#pragma comment(linker, "/STACK:64000000")
using namespace std;
using namespace std;
bool comparer(pair<int, int> l, pair<int, int> r) {
  if (l.first == r.first) return l.second > r.second;
  return l.first < r.first;
}
int main() {
  int n;
  cin >> n;
  pair<int, int> a[1 << 17];
  for (int i = 0; i < n; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    a[i] = make_pair(x, y);
  }
  sort(a, a + n, comparer);
  int ans = 0;
  int cur = 0;
  for (int i = 1; i < n; ++i) {
    if (a[cur].first <= a[i].first && a[cur].second >= a[i].second)
      ans++;
    else
      cur = i;
  }
  cout << ans;
  return 0;
}
