#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e4 + 5;
int n, flg, tmp, mx, mn, ans = 1;
int a[2][maxn], vis[2][maxn];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &a[0][i], &a[1][i]);
    if (a[0][i] == a[0][i - 1] && a[1][i] == a[1][i - 1]) {
      continue;
    }
    if (a[1 - flg][i] >= a[flg][i - 1]) {
      tmp = min(a[1][i], a[0][i]);
      ans += tmp - a[flg][i - 1];
      if (a[0][i - 1] != a[1][i - 1]) ans++;
    }
    flg = a[0][i] > a[1][i] ? 0 : 1;
  }
  printf("%d", ans);
  return 0;
}
