#include <bits/stdc++.h>
using namespace std;
int n, m, k, i, c, b, a, energy, ans, s, j, w[2555555], l[540000], kol;
pair<int, int> p[2555555];
int main() {
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> a >> b;
    p[i] = make_pair(a, b);
  }
  sort(p + 1, p + 1 + n);
  kol = p[1].second;
  for (i = 1; i <= n; i++) {
    if (kol > p[i].second)
      ans++;
    else
      kol = p[i].second;
  }
  cout << ans;
  return 0;
}
