#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-12;
const int N = 1e6 + 5;
const long long mod = 1e9 + 7;
const int oo = 1e9;
int n, t[N], m1, m2, ans = 1;
int a[N], b[N];
bool team1, team2, draw = 1;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
  if (n == 1) {
    cout << min(a[0], b[0]) + 1;
    return 0;
  }
  for (int i = 0; i < n; i++) {
    if (team1) {
      if (a[i] <= b[i])
        ans += max(0, (a[i] - m1 + 1));
      else
        ans += max(0, b[i] - m1 + 1);
    } else if (team2) {
      if (a[i] >= b[i])
        ans += max(0, (b[i] - m2 + 1));
      else
        ans += max(0, a[i] - m2 + 1);
    } else if (draw) {
      ans += min(a[i], b[i]) - m1;
    }
    if (a[i] > b[i]) {
      team1 = 1;
      team2 = 0;
      draw = 0;
    } else if (b[i] > a[i]) {
      team2 = 1;
      team1 = 0;
      draw = 0;
    } else {
      draw = 1;
      team1 = 0;
      team2 = 0;
    }
    m1 = a[i];
    m2 = b[i];
  }
  cout << ans;
}
