#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000;
char buffer[maxn], *S, *TT;
inline char Get_Char() {
  if (S == TT) {
    TT = (S = buffer) + fread(buffer, 1, maxn, stdin);
    if (S == TT) return EOF;
  }
  return *S++;
}
inline int read() {
  char c;
  int re = 0, f = 0;
  for (c = Get_Char(); c < '0' or c > '9'; c = Get_Char())
    if (c == '-') f = 1;
  for (; c >= '0' and c <= '9';)
    re = (re << 1) + (re << 3) + (c - '0'), c = Get_Char();
  if (f) return -re;
  return re;
}
inline void read(int &x) {
  char c;
  int re = 0, f = 0;
  for (c = Get_Char(); c < '0' or c > '9'; c = Get_Char())
    if (c == '-') f = 1;
  for (; c >= '0' and c <= '9';)
    re = (re << 1) + (re << 3) + (c - '0'), c = Get_Char();
  if (f)
    x = -re;
  else
    x = re;
}
inline void _swap(int &x, int &y) { x ^= y ^= x ^= y; }
inline int _abs(const int &x) { return x > 0 ? x : -x; }
inline int _max(const int &x, const int &y) { return x > y ? x : y; }
inline int _min(const int &x, const int &y) { return x < y ? x : y; }
const int N = 3e5 + 5;
namespace treap {
struct Treap {
  struct node {
    int son[2], va, pri, siz, laz;
  } tr[N];
  int st[N], top, tot;
  int rt;
  inline void pushup(const int &x) {
    tr[x].siz = tr[tr[x].son[0]].siz + tr[tr[x].son[1]].siz + 1;
  }
  inline int newnode(const int &va) {
    int cnt;
    if (top)
      cnt = st[top--];
    else
      cnt = ++tot;
    tr[cnt].va = va, tr[cnt].son[0] = tr[cnt].son[1] = tr[cnt].laz = 0,
    tr[cnt].siz = 1, tr[cnt].pri = rand();
    return cnt;
  }
  inline void change(const int &x, const int &va) {
    if (!x) return;
    tr[x].laz += va, tr[x].va += va;
  }
  inline void pushdown(const int &x) {
    if (!x or !tr[x].laz) return;
    change(tr[x].son[0], tr[x].laz), change(tr[x].son[1], tr[x].laz);
    tr[x].laz = 0;
  }
  int merge(const int &x, const int &y) {
    if (!x or !y) return x + y;
    pushdown(x), pushdown(y);
    if (tr[x].pri < tr[y].pri) {
      tr[x].son[1] = merge(tr[x].son[1], y);
      pushup(x);
      return x;
    } else {
      tr[y].son[0] = merge(x, tr[y].son[0]);
      pushup(y);
      return y;
    }
  }
  void split(int now, int k, int &x, int &y) {
    if (!now) {
      x = y = 0;
      return;
    }
    pushdown(now);
    if (tr[now].va <= k)
      x = now, split(tr[now].son[1], k, tr[now].son[1], y);
    else
      y = now, split(tr[now].son[0], k, x, tr[now].son[0]);
    pushup(now);
  }
  inline int kth(int now, int k) {
    if (!k) return 0;
    for (;;) {
      if (tr[tr[now].son[0]].siz == k - 1) return now;
      if (tr[tr[now].son[0]].siz >= k)
        now = tr[now].son[0];
      else
        k -= tr[tr[now].son[0]].siz + 1, now = tr[now].son[1];
    }
  }
  inline int pre(const int &va) {
    int a, b, ret;
    split(rt, va - 1, a, b), ret = kth(a, tr[a].siz), rt = merge(a, b);
    return ret;
  }
  inline int nxt(const int &va) {
    int a, b, ret;
    split(rt, va, a, b), ret = kth(b, 1), rt = merge(a, b);
    return ret;
  }
  inline void insert(const int &va) {
    int a, b;
    split(rt, va, a, b), rt = merge(merge(a, newnode(va)), b);
  }
  inline void del(const int &va) {
    int a, b, c, d;
    split(rt, va, a, b), split(a, va - 1, c, d),
        st[++top] = d, d = merge(tr[d].son[0], tr[d].son[1]),
        rt = merge(merge(c, d), b);
  }
  inline void modify(const int &l, const int &r) {
    int a, b, c, d;
    split(rt, l - 1, a, b), split(b, r, c, d), change(c, 1),
        rt = merge(a, merge(c, d));
  }
};
}  // namespace treap
int n, dp[N];
treap::Treap T;
int main() {
  read(n);
  for (int i = 1; i <= n; ++i) {
    int l, r;
    read(l), read(r);
    if (i == 1)
      T.insert(l);
    else {
      int t = T.nxt(r - 1);
      T.modify(l, r - 1);
      if (t) T.del(T.tr[t].va);
      T.insert(l);
    }
  }
  if (!T.rt)
    return puts("0") * 0;
  else
    cout << T.tr[T.rt].siz << '\n';
}
