#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, cnt = 0;
  cin >> n;
  long long int d = 0, ans = 1;
  vector<pair<int, int> > v(n + 1, pair<int, int>(0, 0));
  for (int(i) = 0; (i) < n; (i)++) cin >> v[i + 1].first >> v[i + 1].second;
  for (int i = 1; i <= n; i++) {
    if (v[i - 1].first == v[i - 1].second) {
      int cd = min(v[i].first, v[i].second);
      if (cd > v[i - 1].first) {
        ans += (cd - v[i - 1].first);
      }
    } else {
      int m = min(v[i].first, v[i].second) -
              max(v[i - 1].first, v[i - 1].second) + 1;
      if (m > 0) ans += m;
    }
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int test = 1;
  while (test--) {
    solve();
  }
  return 0;
}
