#include <bits/stdc++.h>
using namespace std;
template <class T>
void chmin(T& t, T f) {
  if (t > f) t = f;
}
template <class T>
void chmax(T& t, T f) {
  if (t < f) t = f;
}
struct Node {
  int x, y;
} a[200000];
int cmp(const void* a, const void* b) {
  Node c = *((Node*)a);
  Node d = *((Node*)b);
  if (c.x == d.x) return c.y < d.y ? -1 : 1;
  return c.x < d.x ? -1 : 1;
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i].x >> a[i].y;
  qsort(a, n, sizeof(Node), cmp);
  int ans = 0, end = a[0].y;
  for (int i = 1; i < n; ++i) {
    if (a[i].y < end)
      ans++;
    else
      end = a[i].y;
  }
  cout << ans << endl;
  return 0;
}
