#include <bits/stdc++.h>
using namespace std;
struct awsl {
  long long a, b;
} q1[10005];
int main() {
  long long n, x, y, ans(1), a, b;
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%lld %lld", &q1[i].a, &q1[i].b);
  }
  x = y = 0;
  for (int i = 0; i < n; i++) {
    a = q1[i].a;
    b = q1[i].b;
    if (x == y) {
      ans += min(a - x, b - y);
    } else {
      if (min(a, b) - max(x, y) + 1 < 0) {
        x = a, y = b;
        continue;
      }
      ans += min(a, b) - max(x, y) + 1;
    }
    x = a, y = b;
  }
  cout << ans << '\n';
}
