#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, ans = 1;
  cin >> n;
  long long aa, bb;
  cin >> aa >> bb;
  ans += min(aa, bb);
  for (int i = 1; i < n; i++) {
    long long a, b;
    cin >> a >> b;
    if (aa != a || bb != b) {
      long long mini = min(a, b);
      long long maxi = max(aa, bb);
      if (maxi <= mini) {
        ans += mini - maxi;
        if (aa != bb) ans++;
      }
    }
    aa = a;
    bb = b;
  }
  cout << ans << "\n";
  return 0;
}
