#include <bits/stdc++.h>
using namespace std;
int q;
const int maxn = 3e5 + 10;
const int big = 1e9;
int n, l, r, ans;
int random(int x) { return ((1ll * rand() << 16) + rand()) % x; }
struct treap {
  treap *ls, *rs;
  int key, priority;
  int push;
  treap(int x) {
    key = x;
    push = 0;
    priority = random(big);
    ls = rs = nullptr;
  }
};
void down(treap *root) {
  if (root->ls != nullptr) {
    root->ls->key += root->push;
    root->ls->push += root->push;
  }
  if (root->rs != nullptr) {
    root->rs->key += root->push;
    root->rs->push += root->push;
  }
  root->push = 0;
}
void split(treap *root, treap *&left, treap *&right, int x) {
  if (root == nullptr) {
    left = nullptr;
    right = nullptr;
    return;
  }
  if (root->push != 0) down(root);
  if (root->key <= x) {
    split(root->rs, root->rs, right, x);
    left = root;
  } else {
    split(root->ls, left, root->ls, x);
    right = root;
  }
}
void merge_tr(treap *&root, treap *left, treap *right) {
  if (left == nullptr || right == nullptr) {
    if (right == nullptr)
      root = left;
    else
      root = right;
    return;
  }
  down(left);
  down(right);
  if (left->priority > right->priority) {
    merge_tr(left->rs, left->rs, right);
    root = left;
  } else {
    merge_tr(right->ls, left, right->ls);
    root = right;
  }
}
treap *del(treap *root) {
  if (root == nullptr) return nullptr;
  down(root);
  if (root->ls == nullptr)
    root = root->rs;
  else
    root->ls = del(root->ls);
  return root;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  treap *root = nullptr;
  for (int i = 1; i <= n; i++) {
    cin >> l >> r;
    treap *L, *R, *MID;
    split(root, MID, R, r - 1);
    split(MID, L, MID, l - 1);
    if (MID != nullptr) {
      MID->key++;
      MID->push++;
    }
    if (R != nullptr) ans--;
    R = del(R);
    treap *vr = new treap(l);
    merge_tr(root, L, vr);
    merge_tr(root, root, MID);
    merge_tr(root, root, R);
  }
  cout << n + ans << "\n";
  return 0;
}
