#include <bits/stdc++.h>
using namespace std;
int n, nz;
vector<pair<int, int> > v;
set<int> s;
int main() {
  cin >> n;
  while (n--) {
    int x, y;
    cin >> x >> y;
    v.push_back(make_pair(x, y));
    s.insert(y);
  }
  sort(v.begin(), v.end());
  for (int i = v.size() - 1; i >= 0; i--) {
    auto x = s.upper_bound(v[i].second);
    if (x != s.end()) nz++;
    s.erase(v[i].second);
  }
  cout << nz << endl;
}
