#include <bits/stdc++.h>
using namespace std;
long long a[200005], b[200005];
vector<pair<long long, long long> > v;
int main() {
  long long n, i, mn = INT_MIN, x, cnt = 0, y;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    v.push_back({a[i], b[i]});
  }
  sort(v.begin(), v.end());
  for (i = 0; i < n; i++) {
    y = v[i].second;
    mn = max(mn, y);
    if (i == 0)
      continue;
    else {
      x = v[i].second;
      if (x < mn) cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
