#include <bits/stdc++.h>
using namespace std;
inline long long rd() {
  long long _x = 0;
  int _ch = getchar(), _f = 1;
  for (; !isdigit(_ch) && (_ch != '-') && (_ch != EOF); _ch = getchar())
    ;
  if (_ch == '-') {
    _f = 0;
    _ch = getchar();
  }
  for (; isdigit(_ch); _ch = getchar()) _x = _x * 10 + _ch - '0';
  return _f ? _x : -_x;
}
void write(long long _x) {
  if (_x >= 10)
    write(_x / 10), putchar(_x % 10 + '0');
  else
    putchar(_x + '0');
}
inline void wrt(long long _x, char _p) {
  if (_x < 0) putchar('-'), _x = -_x;
  write(_x);
  if (_p) putchar(_p);
}
struct node {
  node *ls, *rs;
  int v, lazy, rnd;
} * root;
void pushdown(node *now) {
  if (now->ls) now->ls->v += now->lazy, now->ls->lazy += now->lazy;
  if (now->rs) now->rs->v += now->lazy, now->rs->lazy += now->lazy;
  now->lazy = 0;
}
void split(node *now, int k, node *&x, node *&y) {
  if (!now) return x = y = NULL, void();
  pushdown(now);
  if (now->v <= k)
    x = now, split(now->rs, k, x->rs, y);
  else
    y = now, split(now->ls, k, x, y->ls);
}
node *merge(node *x, node *y) {
  if (!x || !y) return x == NULL ? y : x;
  pushdown(x), pushdown(y);
  if (x->rnd < y->rnd)
    return x->rs = merge(x->rs, y), x;
  else
    return y->ls = merge(x, y->ls), y;
}
void delmin(node *&rt) {
  node *now = rt;
  if (now == NULL) return;
  node *_hot = NULL;
  while (now->ls) {
    _hot = now;
    now = now->ls;
  }
  if (rt == now) rt = rt->rs;
  if (_hot != NULL) _hot->ls = now->rs;
  delete now;
}
int dfs(node *now) {
  if (now == NULL) return 0;
  int sum = 1;
  sum += dfs(now->ls);
  sum += dfs(now->rs);
  return sum;
}
int n;
pair<int, int> a[300005];
int main() {
  srand(998244353);
  n = rd();
  for (int i = int(1); i <= (int)(n); i++) {
    a[i].first = rd(), a[i].second = rd();
  }
  root = NULL;
  for (int i = int(1); i <= (int)(n); i++) {
    node *x = NULL, *y = NULL, *z = NULL;
    split(root, a[i].first - 1, x, y);
    split(y, a[i].second - 1, y, z);
    node *p = new node;
    p->ls = p->rs = NULL, p->v = a[i].first, p->lazy = 0, p->rnd = rand();
    if (y != NULL) y->lazy++, y->v++;
    delmin(z);
    root = merge(merge(x, p), merge(y, z));
  }
  wrt(dfs(root), '\n');
}
