#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 100, PI = 3.14159265359, M = 1e9 + 7;
long long a[N], ans = 1;
int main() {
  long long n;
  cin >> n;
  long long x = 0, y = 0;
  for (int i = 0; i < n; i++) {
    long long a, b;
    cin >> a >> b;
    long long t1 = a - x, t2 = b - x;
    if (x == y) {
      ans += min(a, b) - x;
    } else if (x < y) {
      if (y <= a) {
        x = y;
        ans += min(a, b) - x + 1;
      }
    } else if (x > y) {
      if (x <= b) {
        y = x;
        ans += min(a, b) - x + 1;
      }
    }
    x = a, y = b;
  }
  cout << ans;
}
