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