#include <bits/stdc++.h>
using namespace std;
const int mx = 105;
bool good[mx];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int l, r;
  cin >> l >> r;
  n--;
  for (int i = l; i < r; i++) good[i] = true;
  for (int i = 0; i < n; i++) {
    cin >> l >> r;
    for (int i = l; i < r; i++) good[i] = false;
  }
  int ret = 0;
  for (int i = 0; i < mx; i++)
    if (good[i]) ret++;
  cout << ret << endl;
  return 0;
}
