#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
pair<int, int> a[N];
int n;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i].first >> a[i].second;
  sort(a, a + n);
  int ans = 0;
  int mxb = -1;
  for (int i = 0; i < n; ++i) {
    if (a[i].second < mxb)
      ++ans;
    else
      mxb = a[i].second;
  }
  cout << ans << "\n";
  return 0;
}
