#include <bits/stdc++.h>
using namespace std;
inline int min(int a, int b) { return a > b ? b : a; }
inline int max(int a, int b) { return a > b ? a : b; }
long long n, s = 1;
int main() {
  std::ios::sync_with_stdio(0);
  cin >> n;
  int a, b, c = 0, d = 0;
  while (n--) {
    cin >> a >> b;
    if (c == d)
      s += (min(a, b) - c);
    else if (c > d) {
      if (b >= c) s += min(a, b) - c + 1;
    } else if (a >= d) {
      s += min(a, b) - d + 1;
    }
    c = a;
    d = b;
  }
  cout << s;
}
