#include <bits/stdc++.h>
int min(int a, int b) {
  if (a <= b) return a;
  return b;
}
int max(int a, int b) {
  if (a >= b) return a;
  return b;
}
int main() {
  int n, s1, s2, count = 1;
  int last1 = 0, last2 = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &s1, &s2);
    int m = min(s1, s2);
    int mi = max(last1, last2);
    if (m > mi) {
      if (last1 == last2) {
        count += m - mi;
      } else {
        count += m - mi + 1;
      }
    } else if (m == mi) {
      if (last1 != last2) count++;
    }
    last1 = s1, last2 = s2;
  }
  printf("%d\n", count);
  return 0;
}
