#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char cc = getchar();
  while (cc < '0' || cc > '9') {
    if (cc == '-') f = -1;
    cc = getchar();
  }
  while (cc >= '0' && cc <= '9') {
    x = x * 10 + cc - '0';
    cc = getchar();
  }
  return x * f;
}
int n, ans, a, b;
int main() {
  n = read();
  ans = 1;
  for (int i = 1; i <= n; i++) {
    int c = read();
    int d = read();
    if (a == c && b == d) continue;
    if (a == b) ans--;
    if (a <= b && b <= c && c <= d)
      ans += c - b + 1;
    else if (a <= b && b <= d && d <= c)
      ans += d - b + 1;
    else if (b <= a && a <= c && c <= d)
      ans += c - a + 1;
    else if (b <= a && a <= d && d <= c)
      ans += d - a + 1;
    a = c;
    b = d;
  }
  printf("%d", ans);
}
