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