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