#include <bits/stdc++.h>
using namespace std;
struct data {
  int s, t;
  bool operator<(const data& a) const { return s < a.s; }
} d[100005];
int main() {
  int n;
  while (scanf("%d", &n) == 1) {
    for (int i = 0; i < n; ++i) {
      scanf("%d %d", &d[i].s, &d[i].t);
    }
    sort(d, d + n);
    int endtime = 0;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
      if (d[i].t < endtime)
        ans++;
      else
        endtime = d[i].t;
    }
    printf("%d\n", ans);
  }
  return 0;
}
