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