#include <bits/stdc++.h>
using namespace std;
int a[10005][2], sum = 1;
int g(int s1, int s2, int s3) { return min(max(0, s2 - s1 + 1), s3 - s1 + 1); }
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i][0] >> a[i][1];
  }
  for (int i = 1; i <= n; i++) {
    if (a[i - 1][0] == a[i - 1][1]) {
      sum += min(a[i][0], a[i][1]) - a[i - 1][0];
    } else if (a[i - 1][0] < a[i - 1][1]) {
      sum += g(a[i - 1][1], a[i][0], a[i][1]);
    } else {
      sum += g(a[i - 1][0], a[i][1], a[i][0]);
    }
  }
  cout << sum;
}
