#include <bits/stdc++.h>
const long long int mod = 1000000007;
long long int powmod(long long int a, long long int b) {
  long long int res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
long long int gcd(long long int a, long long int b) {
  return b ? gcd(b, a % b) : a;
}
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<pair<long long int, long long int> > v(n + 1);
  v[0] = {0, 0};
  for (int i = 1; i <= n; ++i) {
    long long int a, b;
    cin >> a >> b;
    v[i] = {a, b};
  }
  long long int ans = 1;
  long long int a, b, c, d;
  a = 0, b = 0;
  for (int i = 1; i <= n; ++i) {
    c = v[i].first;
    d = v[i].second;
    long long int tans = max(0LL, min(c, d) - max(a, b) + 1);
    if (c == a && d == b) continue;
    if (a == b) tans--;
    ans += tans;
    a = c, b = d;
  }
  cout << ans;
  return 0;
}
