#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, i = 0;
  cin >> n;
  long long int sum = 0;
  vector<pair<long long int, long long int> > v(n);
  for (i = 0; i < n; i = i + 1) {
    cin >> v[i].first >> v[i].second;
    long long int x = v[i].first;
    long long int y = v[i].second;
    if (i == 0) {
      sum = sum + min(x, y) + 1;
    } else {
      if (v[i - 1].first != v[i - 1].second)
        sum = sum +
              max(min(x, y) - max(v[i - 1].first, v[i - 1].second) + 1LL, 0LL);
      else {
        sum = sum + max(min(x, y) - max(v[i - 1].first, v[i - 1].second), 0LL);
      }
    }
  }
  cout << sum << endl;
}
