#include <bits/stdc++.h>
const int INF = (int)1e9;
const int mod = (int)1e9 + 7;
const int MAXN = (int)3e5 + 5;
using namespace std;
pair<int, int> pr[2];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n;
  cin >> n;
  int a1 = 0, b1 = 0, a2, b2;
  int ans = 1;
  for (int i = 0; i < n; i++) {
    cin >> a2 >> b2;
    pr[0] = make_pair(a1, a2);
    pr[1] = make_pair(b1, b2);
    sort(pr, pr + 2);
    a1 = a2, b1 = b2;
    if (pr[0].second < pr[1].first) {
      continue;
    } else if (pr[0].second >= pr[1].first && pr[0].second <= pr[1].second) {
      ans += pr[0].second - pr[1].first + (pr[0].first != pr[1].first);
    } else if (pr[0].second > pr[1].second) {
      ans += pr[1].second - pr[1].first + (pr[0].first != pr[1].first);
    }
  }
  cout << ans << '\n';
}
