#include <bits/stdc++.h>
using namespace std;
int a[105] = {0};
int n, x, y;
void Read(void) {
  cin >> n >> x >> y;
  for (int i = x; i <= y; ++i) a[i] = 1;
}
int Solve(void) {
  int l, r;
  n--;
  while (n--) {
    cin >> l >> r;
    for (int i = l; i < r; ++i) a[i] = 0;
  }
  return cout << accumulate(a + x, a + y, 0), 0;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  ;
  Read();
  Solve();
  return 0;
}
