#include <bits/stdc++.h>
using namespace std;
long long ans, sum, mn = 1e18, mx, cnt;
long long temp, temp2;
int main() {
  long long n;
  cin >> n;
  vector<pair<long long, long long> > v;
  for (long long i = 0; i < n; i++) {
    long long a, b;
    cin >> a >> b;
    v.push_back(make_pair(a, b));
  }
  sort(v.begin(), v.end());
  temp = v[0].first, temp2 = v[0].second;
  for (long long i = 1; i < n; i++) {
    if (v[i].first > temp && v[i].second < temp2)
      ans++;
    else {
      temp = v[i].first;
      temp2 = v[i].second;
    }
  }
  cout << ans << endl;
}
