#include <bits/stdc++.h>
using namespace std;
map<string, int> mp, mp1;
int vis[200005];
long long solve(int x) {
  int i, j, k;
  long long sum = 0;
  memset(vis, 0, sizeof(vis));
  for (i = 0; i <= x; i++) {
    for (j = 0; i + j <= x; j++) {
    }
  }
}
long long fsum(long long a, long long b, long long c) {
  long long ans = 0;
  while (b) {
    if (b % 2 == 1) {
      ans = (ans + a) % c;
    }
    a = (a + a) % c;
    b = b / 2;
  }
  return ans;
}
long long f(long long a, long long b, long long c) {
  long long ans = 1;
  a = a % c;
  while (b) {
    if (b % 2 == 1) {
      ans = (ans * a) % c;
    }
    a = (a * a) % c;
    b = b / 2;
  }
  return ans;
}
long long dp[4][200005];
long long mod = 1e9 + 7;
struct node {
  double x;
  double y;
} a[200005];
double w(node a[], int n) {
  int i;
  double sum = 0;
  for (i = 1; i <= n; i++) {
    sum += a[i - 1].x * a[i % n].y - a[i - 1].y * a[i % n].x;
  }
  return fabs(sum / 2.0);
}
int main() {
  int n;
  cin >> n;
  int i, j;
  int xx, yy;
  long long ans = 1;
  scanf("%d%d", &xx, &yy);
  int min1, max1, min2, max2;
  min1 = min(xx, yy);
  max1 = max(xx, yy);
  if (min1 > 0 && max1 > 0) {
    ans += min1;
  }
  for (i = 2; i <= n; i++) {
    int a, b;
    cin >> a >> b;
    min2 = min(a, b);
    max2 = max(a, b);
    if (min2 >= max1) {
      if (min1 == max1) {
        ans += min2 - max1;
      } else {
        ans += min2 - max1 + 1;
      }
    }
    min1 = min2;
    max1 = max2;
  }
  cout << ans << endl;
  return 0;
}
