#include <bits/stdc++.h>
using namespace std;
void solve();
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  solve();
  return 0;
}
void solve() {
  int64_t n;
  cin >> n;
  vector<pair<int64_t, int64_t> > ar;
  for (int64_t i = 0; i < n; i++) {
    int64_t x, y;
    cin >> x >> y;
    ar.push_back(pair<int64_t, int64_t>(x, y));
  }
  sort(ar.begin(), ar.end());
  int64_t en = 0;
  int64_t ans = 0;
  for (int64_t i = 0; i < n; i++) {
    if (ar[i].second < en) ans++;
    en = max(en, ar[i].second);
  }
  cout << ans << "\n";
}
