#include <bits/stdc++.h>
using namespace std;
template <typename T>
T id(T b) {
  return b;
};
template <class It>
bool all(It f, It l) {
  return std::all_of(f, l, id<bool>);
}
template <class It>
bool any(It f, It l) {
  return std::any_of(f, l, id<bool>);
}
template <typename T>
void chmax(T &x, T y) {
  if (x < y) x = y;
}
template <typename T>
void chmin(T &x, T y) {
  if (x > y) x = y;
}
const int MAX_N = 10000;
int n;
int a[MAX_N + 1];
int b[MAX_N + 1];
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i] >> b[i];
  }
  a[0] = b[0] = 0;
  long long res = 1;
  for (int i = 1; i <= n; ++i) {
    int l = max(a[i - 1], b[i - 1]);
    int r = min(a[i], b[i]);
    if (l <= r) res += r - l + (a[i - 1] == b[i - 1] ? 0 : 1);
  }
  cout << res << endl;
  return 0;
}
