#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int x = 0, y = 0, ans = 1;
  for (int i = 1; i <= n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    int delta = 0;
    if (x < y) {
      delta = min(y - x, a - x);
      x += delta;
    } else {
      delta = min(x - y, b - y);
      y += delta;
    }
    if (x == y) {
      if (delta > 0) ++ans;
      delta = min(a - x, b - y);
      x += delta;
      y += delta;
      ans += delta;
    }
    x = a;
    y = b;
  }
  printf("%d\n", ans);
  return 0;
}
