#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N;
  cin >> N;
  vector<pair<int, int> > v(N);
  for (int i = 0; i < N; i++) cin >> v[i].first >> v[i].second;
  sort(v.begin(), v.end());
  int ans = 0, mx = v[0].second;
  for (int i = 1; i < N; i++)
    if (mx > v[i].second)
      ans++;
    else
      mx = v[i].second;
  cout << ans << endl;
  return 0;
}
