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