#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  long long x, y, ans = 1;
  pair<long long, long long> p[n];
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    p[i] = make_pair(x, y);
  }
  bool f = 0, l = 0, d = 0;
  for (int i = 0; i < n; i++) {
    if (i == 0) {
      ans += min(p[i].first, p[i].second);
      if (p[i].first > p[i].second)
        l = 1, f = 0, d = 0;
      else if (p[i].first < p[i].second)
        f = 1, l = 0, d = 0;
      else
        d = 1, f = 0, l = 0;
    } else if (d) {
      ans += min(p[i].first, p[i].second) - p[i - 1].first;
      if (p[i].first > p[i].second)
        l = 1, f = 0, d = 0;
      else if (p[i].first < p[i].second)
        f = 1, l = 0, d = 0;
      else
        d = 1, f = 0, l = 0;
    } else if (l) {
      if (p[i].second >= p[i - 1].first) {
        ans++;
        if (p[i].first > p[i].second)
          ans += p[i].second - p[i - 1].first;
        else if (p[i].first < p[i].second)
          ans += p[i].first - p[i - 1].first;
        else
          ans += p[i].first - p[i - 1].first;
      }
      if (p[i].first > p[i].second)
        l = 1, f = 0, d = 0;
      else if (p[i].first < p[i].second)
        f = 1, l = 0, d = 0;
      else
        d = 1, f = 0, l = 0;
    } else if (f) {
      if (p[i].first >= p[i - 1].second) {
        ans++;
        if (p[i].first > p[i].second)
          ans += p[i].second - p[i - 1].second;
        else if (p[i].first < p[i].second)
          ans += p[i].first - p[i - 1].second;
        else
          ans += p[i].second - p[i - 1].second;
      }
      if (p[i].first > p[i].second)
        l = 1, f = 0, d = 0;
      else if (p[i].first < p[i].second)
        f = 1, l = 0, d = 0;
      else
        d = 1, f = 0, l = 0;
    }
  }
  cout << ans;
  return 0;
}
