#include <bits/stdc++.h>
using namespace std;
vector<long long> pwx(61);
void cal(long long x) {
  pwx[0] = 1;
  for (long long i = 1; i < 61; i++) pwx[i] = x * pwx[i - 1];
}
int main() {
  long long n;
  cin >> n;
  vector<pair<long long, long long>> a(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i].second >> a[i].first;
  }
  sort(a.begin(), a.end(), greater<pair<long long, long long>>());
  long long ans = 0, l = a[0].second;
  for (long long i = 1; i < n; i++) {
    if (a[i].second > l)
      ans++;
    else
      l = a[i].second;
  }
  cout << ans << '\n';
  return 0;
}
