#include <bits/stdc++.h>
using namespace std;
long long ans = 0;
void solve(long long c1, long long c2, long long l1, long long l2) {
  if (c1 == c2) {
    if (l1 == l2) {
      ans += (c1 - l1);
      return;
    }
    ans += min(c1 - l1 + 1, c2 - l2 + 1);
    return;
  }
  if (l1 == l2) {
    ans += min(c1 - l1, c2 - l2);
    return;
  }
  if (c1 > c2) {
    if (l1 > l2) {
      if (c2 >= l1) {
        ans += (c2 - l1 + 1);
        return;
      } else {
        return;
      }
    }
    if (l2 > l1) {
      ans += (c2 - l2 + 1);
    }
  }
  if (c2 > c1) {
    solve(c2, c1, l2, l1);
    return;
  }
  return;
}
int main() {
  long long n, l1, c1, l2, c2;
  cin >> n;
  l1 = 0;
  l2 = 0;
  for (long long i = 1; i <= n; i++) {
    cin >> c1 >> c2;
    solve(c1, c2, l1, l2);
    l1 = c1;
    l2 = c2;
  }
  cout << ans + 1;
}
