#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  long long int a = 0, b = 0, c, d, ans = 1;
  for (int i = int(1); i <= int(n); i++) {
    cin >> c >> d;
    if (max(a, b) <= min(c, d)) {
      if (a == b)
        ans += min(c, d) - max(a, b);
      else
        ans += min(c, d) - max(a, b) + 1;
    }
    a = c;
    b = d;
  }
  cout << ans << endl;
}
