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