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