#include <bits/stdc++.h>
using namespace std;
class Solution {
 public:
  int maxDraw(const vector<int>& a, const vector<int>& b) {
    int res = 1;
    for (int i = 1; i < a.size(); i++)
      if (min(a[i], b[i]) >= max(a[i - 1], b[i - 1])) {
        int t = max(a[i - 1], b[i - 1]);
        if (a[i - 1] != b[i - 1]) res++;
        res += min(a[i], b[i]) - t;
      }
    return res;
  }
};
int main() {
  int n;
  cin >> n;
  vector<int> a(n + 1, 0), b(n + 1, 0);
  for (int i = 1; i <= n; i++) cin >> a[i] >> b[i];
  cout << Solution().maxDraw(a, b) << endl;
  return 0;
}
