#include <bits/stdc++.h>
using namespace std;
long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
long long n, q;
struct FHQTreap {
  long long val[300005], rnd[300005], tag[300005], rev[300005], siz[300005],
      Mx[300005], ch[300005][2], rt, cnt;
  long long Get(long long x) {
    val[++cnt] = x;
    siz[cnt] = 1;
    rnd[cnt] = rand();
    return cnt;
  }
  void pushup(long long x) {
    siz[x] = siz[ch[x][0]] + siz[ch[x][1]] + 1;
    return;
  }
  void pushdown(long long x) {
    if (tag[x]) {
      tag[ch[x][0]] += tag[x];
      tag[ch[x][1]] += tag[x];
      val[ch[x][0]] += tag[x];
      val[ch[x][1]] += tag[x];
      tag[x] = 0;
    }
    pushup(x);
  }
  long long merge(long long x, long long y) {
    if (!x || !y) return x + y;
    if (rnd[x] < rnd[y]) {
      pushdown(x);
      ch[x][1] = merge(ch[x][1], y);
      pushup(x);
      return x;
    } else {
      pushdown(y);
      ch[y][0] = merge(x, ch[y][0]);
      pushup(y);
      return y;
    }
  }
  void split(long long now, long long k, long long &x, long long &y) {
    if (!now) {
      x = y = 0;
      return;
    }
    pushdown(now);
    if (val[now] <= k)
      x = now, split(ch[now][1], k, ch[x][1], y);
    else
      y = now, split(ch[now][0], k, x, ch[y][0]);
    pushup(now);
  }
  void insert(long long x) {
    long long A, B;
    split(rt, x, A, B);
    rt = merge(merge(A, Get(x)), B);
  }
  long long kth(long long now, long long k) {
    if (!k) return now;
    if (siz[ch[now][0]] + 1 > k) return kth(ch[now][0], k);
    if (siz[ch[now][0]] + 1 == k) return now;
    return kth(ch[now][1], k - siz[ch[now][0]] - 1);
  }
  long long nxt(long long x) {
    long long A, B;
    split(rt, x, A, B);
    long long res = kth(B, 1);
    rt = merge(A, B);
    return res;
  }
  void doit(long long L, long long R) {
    long long A, B, C, D;
    split(rt, L - 1, A, B);
    split(B, R, C, D);
    if (C) val[C]++, tag[C]++;
    rt = merge(merge(A, C), D);
  }
  void del(long long x) {
    long long A, B, C, D;
    split(rt, x, A, B);
    split(A, x - 1, C, D);
    D = merge(ch[D][0], ch[D][1]);
    rt = merge(merge(C, D), B);
  }
} T;
signed main() {
  n = read();
  for (long long i = 1; i <= n; i++) {
    long long L = read(), R = read();
    if (i == 1) {
      T.insert(L);
      continue;
    }
    long long Nxt = T.nxt(R - 1);
    T.doit(L, R - 1);
    if (Nxt) T.del(T.val[Nxt]);
    T.insert(L);
  }
  if (!T.rt)
    puts("0");
  else
    printf("%d\n", T.siz[T.rt]);
  return 0;
}
