#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, draw = 1, a, b, la = 0, lb = 0;
  cin >> n;
  for (long long i = 0; i < n; ++i) {
    cin >> a >> b;
    if (la == lb) draw--;
    draw += max(0LL, min(a, b) - max(la, lb) + 1);
    la = a;
    lb = b;
  }
  cout << draw;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
  return 0;
}
