#include <bits/stdc++.h>
using namespace std;
map<pair<long long, long long>, long long> m;
int main() {
  long long t, ai, bi, dr = 1;
  cin >> t;
  vector<pair<long long, long long>> v(t);
  for (int i = 0; i < t; i++) {
    cin >> ai >> bi;
    v[i] = {ai, bi};
  }
  m[{0, 0}] = 1;
  dr += min(v[0].first, v[0].second);
  m[{v[0].first, v[0].second}] = 1;
  for (int i = 1; i < t; i++) {
    if (v[i].first > v[i - 1].first && v[i].second > v[i - 1].second &&
        m[{v[i].first, v[i].second}] == 0 &&
        min(v[i].first, v[i].second) >= max(v[i - 1].second, v[i - 1].first)) {
      if ((v[i - 1].first != 0 || v[i - 1].second != 0) &&
          v[i - 1].first != v[i - 1].second) {
        dr += min(v[i].first, v[i].second) -
              max(v[i - 1].first, v[i - 1].second) + 1;
      } else {
        dr +=
            min(v[i].first, v[i].second) - max(v[i - 1].first, v[i - 1].second);
      }
      m[{v[i].first, v[i].second}] = 1;
    } else if ((v[i].first > v[i].second && v[i].second == v[i - 1].second &&
                v[i - 1].first < v[i - 1].second) ||
               (v[i].second > v[i].first && v[i].first == v[i - 1].first &&
                v[i - 1].second < v[i - 1].first) &&
                   m[{v[i].first, v[i].second}] == 0) {
      dr++;
      m[{v[i].first, v[i].second}] = 1;
    } else if (v[i].first == v[i].second && m[{v[i].first, v[i].second}] == 0) {
      dr++;
      m[{v[i].first, v[i].second}] = 1;
    }
  }
  cout << dr;
}
