#include <bits/stdc++.h>
using namespace std;
struct Node {
  int key, priority;
  int add = 0;
  Node *left_child = nullptr, *right_child = nullptr;
  Node(const int key) : key(key), priority(rand()) {}
  void propagate() {
    key += add;
    if (left_child) left_child->add += add;
    if (right_child) right_child->add += add;
    add = 0;
  }
};
int size(Node* const root) {
  return root ? 1 + size(root->left_child) + size(root->right_child) : 0;
}
pair<Node*, Node*> split(Node* const root, const int key) {
  if (!root)
    return {nullptr, nullptr};
  else
    root->propagate();
  Node *left, *right;
  if (key <= root->key) {
    right = root;
    tie(left, right->left_child) = split(root->left_child, key);
  } else {
    left = root;
    tie(left->right_child, right) = split(root->right_child, key);
  }
  return {left, right};
}
Node* merge(Node* const left, Node* const right) {
  if (!left || !right)
    return left ? left : right;
  else
    left->propagate(), right->propagate();
  if (left->priority < right->priority) {
    left->right_child = merge(left->right_child, right);
    return left;
  } else {
    right->left_child = merge(left, right->left_child);
    return right;
  }
}
void erase_min(Node*& root) {
  if (!root)
    return;
  else
    root->propagate();
  if (!root->left_child)
    root = root->right_child;
  else
    erase_min(root->left_child);
}
int main() {
  ios::sync_with_stdio(false);
  Node* root = nullptr;
  int n;
  cin >> n;
  while (n--) {
    int l, r;
    cin >> l >> r;
    Node *t1, *t2, *t3;
    tie(t1, t2) = split(root, l);
    tie(t2, t3) = split(t2, r);
    if (t2) t2->add++;
    erase_min(t3);
    root = merge(merge(t1, new Node(l)), merge(t2, t3));
  }
  cout << size(root) << endl;
}
