#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b;
  vector<pair<int, int> > g;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    g.push_back(make_pair(a, b));
  }
  sort(g.begin(), g.end());
  int mx = 0, ans = 0;
  for (int i = 0; i < n; i++) {
    if (g[i].second < mx) ans++;
    mx = max(mx, g[i].second);
  }
  cout << ans << endl;
  return 0;
}
