#include <bits/stdc++.h>
using namespace std;
int n, nox, noy, ax, ay, cnt;
int main() {
  cin >> n;
  while (n--) {
    scanf("%d %d", &ax, &ay);
    if (max(nox, noy) > min(ax, ay))
      ;
    else {
      if (nox != noy) {
        nox = max(nox, noy);
        noy = nox;
        cnt++;
      }
      cnt += (min(ax, ay) - nox);
    }
    nox = ax;
    noy = ay;
  }
  cout << cnt + 1;
}
