#include <bits/stdc++.h>
using namespace std;
int n, ex, ey, xx, yy, ans;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &xx, &yy);
    if (xx < ey || yy < ex) goto ed;
    if (xx == ex && yy == ey) continue;
    ans += min(xx, yy) - max(ex, ey) + (ex != ey);
  ed:
    ex = xx, ey = yy;
  }
  printf("%d\n", ans + 1);
}
