#include <bits/stdc++.h>
using namespace std;
long long int n, a[10005][2];
int main() {
  cin >> n;
  long long int sum = 1;
  cin >> a[0][0] >> a[0][1];
  sum += min(a[0][0], a[0][1]);
  for (int i = 1; i < n; i++) {
    cin >> a[i][0] >> a[i][1];
    if (a[i][0] == a[i - 1][0] && a[i][1] == a[i - 1][1]) continue;
    if (a[i][0] < a[i - 1][1] || a[i][1] < a[i - 1][0])
      continue;
    else {
      int x = max(a[i - 1][0], a[i - 1][1]);
      int y = min(a[i][0], a[i][1]);
      sum += y - x + 1;
      if (a[i - 1][0] == a[i - 1][1]) sum--;
    }
  }
  cout << sum << endl;
  return 0;
}
