#include <bits/stdc++.h>
const long long INF = 1e18;
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  long long x = 0, y = 0, res = 1;
  while (n--) {
    int a, b;
    cin >> a >> b;
    if (a == x && b == y) continue;
    long long first = max(x, y);
    if (x == y) first++;
    if (first <= a && first <= b) res += min(a, b) - first + 1;
    x = a;
    y = b;
  }
  cout << res << "\n";
  return 0;
}
