#include <bits/stdc++.h>
using namespace std;
struct node {
  int x, y;
} r[200000];
int n;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d %d", &r[i].x, &r[i].y);
  long long ans = 1;
  for (int i = 1; i <= n; ++i) {
    if (r[i - 1].x == r[i - 1].y)
      ans += min(r[i].x, r[i].y) - r[i - 1].x;
    else if (r[i - 1].x < r[i - 1].y)
      ans += min(r[i].y - r[i - 1].y + 1, max(r[i].x - r[i - 1].y + 1, 0));
    else
      ans += min(r[i].x - r[i - 1].x + 1, max(r[i].y - r[i - 1].x + 1, 0));
  }
  printf("%lld", ans);
  return 0;
}
