#include <bits/stdc++.h>
using namespace std;
int n;
pair<int, int> a[100000];
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i].first >> a[i].second;
  }
  sort(a, a + n);
  int ans = 0;
  int rightMost = -1;
  for (int i = 0; i < n; ++i) {
    if (a[i].second > rightMost)
      rightMost = a[i].second;
    else
      ans++;
  }
  cout << ans << endl;
}
