#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int ans = 1;
  int xp, yp, x, y;
  xp = yp = 0;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    int d = min(x, y) - max(xp, yp) + 1;
    if (xp == yp) d--;
    if (d > 0) ans += d;
    xp = x;
    yp = y;
  }
  cout << ans << "\n";
}
