#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  pair<long long, long long> p[n];
  for (long long i = 0; i < n; i++) {
    cin >> p[i].first >> p[i].second;
  }
  sort(p, p + n);
  long long c = 0;
  long long mx = p[0].second;
  for (long long i = 1; i < n; i++) {
    if (p[i].second < mx) {
      c++;
    } else {
      mx = p[i].second;
    }
  }
  cout << c;
}
