#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
const double pi = acos(-1.0);
const double eps = 1e-11;
const int MAXI = 0x7fffffff;
using namespace std;
int in() {
  int x = 0, c;
  for (; (unsigned)((c = getchar()) - '0') >= 10;) {
    if (c == '-') return -in();
    if (!~c) throw ~0;
  }
  do {
    x = (x << 3) + (x << 1) + (c - '0');
  } while ((unsigned)((c = getchar()) - '0') < 10);
  return x;
}
int main(int argc, char *argv[]) {
  long n;
  n = in();
  pair<long, long> his[n];
  for (long i = (0), _b = (n); i < _b; i++) {
    his[i].first = in();
    his[i].second = in();
  }
  sort(his, his + n);
  long end, re;
  re = 0;
  end = -1;
  for (long i = (0), _b = (n); i < _b; i++) {
    if (his[i].second < end) re++;
    end = max(end, his[i].second);
  }
  cout << re;
  return 0;
}
