#include <bits/stdc++.h>
using namespace std;
struct node {
  node *l, *r;
  int prior, size, val, prop;
  node(int x) {
    prior = rand();
    val = x;
    size = 1;
    prop = 0;
    l = r = NULL;
  }
};
void prop(node *t) {
  t->val += t->prop;
  if (t->l) t->l->prop += t->prop;
  if (t->r) t->r->prop += t->prop;
  t->prop = 0;
}
void split(node *t, int value, node **L, node **R) {
  if (!t) {
    *L = *R = NULL;
    return;
  }
  prop(t);
  if (t->val >= value) {
    split(t->l, value, L, &t->l);
    *R = t;
  } else {
    split(t->r, value, &t->r, R);
    *L = t;
  }
}
void merge(node *L, node *R, node **T) {
  if (!L) {
    *T = R;
    return;
  }
  if (!R) {
    *T = L;
    return;
  }
  if (L->prior > R->prior) {
    prop(L);
    merge(L->r, R, &L->r);
    *T = L;
  } else {
    prop(R);
    merge(L, R->l, &R->l);
    *T = R;
  }
}
int get_max(node *t) { return t->r ? get_max(t->r) : t->val; }
int get_min(node *t) { return t->l ? get_min(t->l) : t->val; }
int size(node *t) {
  if (!t) return 0;
  return 1 + size(t->l) + size(t->r);
}
void print(node *t) {
  if (!t) return;
  prop(t);
  print(t->l);
  fprintf(stderr, "%d ", t->val);
  print(t->r);
}
const int INF = 2e9;
int main(void) {
  int n;
  scanf("%d", &n);
  node *T, *L, *M, *R;
  T = new node(0);
  for (int i = (0); i < (n); ++i) {
    int l, r;
    scanf("%d%d", &l, &r);
    split(T, l, &L, &R);
    split(R, r, &M, &R);
    node *tmp;
    if (M) {
      M->prop += 1;
      int cnt = get_max(M);
      split(R, cnt + 1, &tmp, &R);
    }
    if (R) {
      split(R, get_min(R) + 1, &tmp, &R);
    }
    merge(L, new node(l), &T);
    merge(T, M, &T);
    merge(T, R, &T);
  }
  printf("%d\n", size(T) - 1);
  return 0;
}
