#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
void solve() {
  int n;
  cin >> n;
  pair<long long, long long> a[n];
  for (int i = 0; i < n; i++) {
    long long s, t;
    cin >> s >> t;
    a[i] = make_pair(s, t);
  }
  sort(a, a + n);
  long long total = 0;
  set<long long> b{};
  b.insert(a[0].second);
  for (int i = 1; i < n; i++) {
    b.insert(a[i].second);
    if (*(--b.end()) != a[i].second) {
      total++;
    }
  }
  cout << total << "\n";
}
int main() {
  {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  }
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
