#include <bits/stdc++.h>
using namespace std;
inline long long GCD(long long a, long long b) { return b ? GCD(b, a % b) : a; }
inline long long LCM(long long a, long long b) { return a / GCD(a, b) * b; }
char str[100010], buf[10];
int num[100010], sum[100010];
bool visited[100010];
struct Event {
  int x, y;
} evt[100010];
int comp(Event a, Event b) {
  if (a.x == b.x) return a.y < b.y;
  return a.x < b.x;
}
int main() {
  int n, i, ans, index;
  while (scanf("%d", &n) != EOF) {
    for (i = 0; i < n; i++) {
      scanf("%d", &evt[i].x);
      scanf("%d", &evt[i].y);
    }
    sort(evt, evt + n, comp);
    ans = 1;
    index = 0;
    for (i = 1; i < n; i++) {
      if (evt[i].x > evt[index].x && evt[i].y < evt[index].y) continue;
      if (evt[i].x >= evt[index].x && evt[i].y <= evt[index].y) {
        ans++;
        index = i;
        continue;
      }
      if (evt[i].x >= evt[index].x && evt[i].y >= evt[index].y) {
        ans++;
        index = i;
        continue;
      }
      if (evt[i].x >= evt[index].y) {
        ans++;
        index = i;
        continue;
      }
    }
    printf("%d\n", n - ans);
  }
  return 0;
}
