#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > Dates;
int n, x, y, ans, cur;
int main() {
  std::ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    Dates.push_back(make_pair(x, y));
  }
  sort(Dates.begin(), Dates.end());
  for (int i = 0; i < Dates.size(); i++) {
    if (Dates[i].second > cur)
      cur = Dates[i].second;
    else if (Dates[i].second < cur) {
      ans++;
    }
  }
  cout << ans << endl;
}
