#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int a[maxn];
int Min = 0x3f3f3f;
int main() {
  int n;
  cin >> n;
  int pa = 0, pb = 0, ans = 1;
  int a, b;
  while (n--) {
    cin >> a >> b;
    if (a == pa && b == pb) continue;
    ans += max(0, min(a, b) - max(pa, pb) + 1);
    if (pa == pb) ans -= 1;
    pa = a;
    pb = b;
  }
  cout << ans << endl;
  return 0;
}
