#include <bits/stdc++.h>
using namespace std;
pair<int, int> p[100001];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &p[i].first, &p[i].second);
  }
  sort(p, p + n);
  int e = 0, ans = 0;
  for (int i = 0; i < n; i++) {
    if (p[i].second < e) ans++;
    e = max(e, p[i].second);
  }
  cout << ans << endl;
  return 0;
}
