#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  long long a = 0, c = 0;
  long long answer = 1;
  for (int z = 0; z < n; z++) {
    long long b, d;
    cin >> b >> d;
    if (b == a && c == d) continue;
    long long temp1, temp2;
    if (c <= b && d >= a) {
      temp1 = max(a, c);
      temp2 = min(b, d);
      answer += abs(temp2 - temp1);
      if (a != c) answer++;
    }
    a = b;
    c = d;
  }
  cout << answer << endl;
  cin >> n;
}
