#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b;
  cin >> n;
  vector<pair<int, int>> v(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> a >> b;
    v[i] = make_pair(a, b);
  }
  sort(v.begin(), v.end());
  int ans = 0, k = 1;
  for (int i = 2; i <= n; i++) {
    for (int j = i - 1; j >= k; j--) {
      if (v[i].first < v[k].second && v[i].second < v[k].second) {
        ans++;
        break;
      }
      if (j == k) {
        k = i;
      }
    }
  }
  cout << ans << endl;
  cin.get();
}
