#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > v;
set<pair<int, pair<int, int> > > s;
int n;
bool is_pref(int pr) {
  int t2 = v[pr].second;
  int t1 = v[pr].first;
  for (int i = pr; i >= 0; i--)
    if (v[i].second < t2) return true;
  return false;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    v.push_back(pair<int, int>(x, y));
  }
  sort(v.begin(), v.end());
  int ans = 0, maxb = v[0].second;
  for (int i = 1; i < n; i++) {
    if (maxb < v[i].second)
      maxb = v[i].second;
    else
      ans++;
  }
  cout << ans << endl;
  return 0;
}
