#include <bits/stdc++.h>
using namespace std;
int a[10005], b[10005];
int main() {
  int n;
  scanf("%d", &n);
  int sum = 1;
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &a[i], &b[i]);
    int q = 0;
    q = a[i] - max(a[i - 1], b[i - 1]);
    int w = 0;
    w = b[i] - max(a[i - 1], b[i - 1]);
    if (min(q, w) >= 0) {
      sum += min(q, w);
      if (a[i - 1] != b[i - 1]) sum++;
    }
  }
  printf("%d\n", sum);
  return 0;
}
