#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  int ans = 1;
  int lasta = 0;
  int lastb = 0;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    if (a == lasta && b == lastb && i > 0) continue;
    int maxi = min(a, b);
    int mini = max(lasta, lastb);
    if (maxi >= mini) {
      ans += maxi - mini + 1;
      if (lasta == lastb) ans--;
    }
    lasta = a;
    lastb = b;
  }
  cout << ans << endl;
}
