#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, i, cnt = 1, a, b, pb = 0, pa = 0;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a >> b;
    cnt += max(min(a, b) - max(pa, pb), 0LL);
    if (pa != pb && min(a, b) >= max(pa, pb)) cnt++;
    pa = a, pb = b;
  }
  cout << cnt;
  return 0;
}
