#include <bits/stdc++.h>
using namespace std;
int n, x, y, px, py, ans = 1;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < int(n); i++) {
    cin >> x >> y;
    if (x == px && y == py) continue;
    ans += max(0, min(x, y) - max(px, py) + (px != py));
    px = x;
    py = y;
  }
  cout << ans;
  return 0;
}
