#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 322;
const long long LINF = 2e18 + 474;
const long long MAXN = 1e4 + 500;
const long long MOD = 1e9 + 7;
const double eps = 1e-12;
long long n, ans = 1;
set<pair<long long, long long>> a;
vector<pair<long long, long long>> v;
void solve() {
  cin >> n;
  a.insert({0, 0});
  for (int i = 0; i < n; i++) {
    pair<long long, long long> x;
    cin >> x.first >> x.second;
    a.insert(x);
  }
  for (auto it = a.begin(); it != a.end(); it++) {
    v.push_back(*it);
  }
  for (int i = 1; i < (long long)v.size(); i++) {
    long long l = max(v[i - 1].first, v[i - 1].second);
    long long r = min(v[i].first, v[i].second);
    ans += max(0LL, r - l);
    if (v[i - 1].first != v[i - 1].second && r >= l) {
      ans++;
    }
  }
  cout << ans;
}
int main() {
  if (!1) {
    freopen(
        "474"
        ".in",
        "r", stdin);
    freopen(
        "474"
        ".out",
        "w", stdout);
  }
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  setlocale(LC_ALL, "Russian");
  int T = 1;
  while (T--) {
    solve();
  }
  return 0;
}
