n, m = map(int, input().split())
max_l = 0
min_r = n
ans = n
for i in range(m):
  l, r = map(int, input().split())
  if ans != 0:
    if l <= min_r or r <= max_l:
      max_l = max(max_l, l)
      min_r = min(min_r, r)
    else:
      ans = 0
if ans != 0:
  ans = min_r - max_l + 1
print(ans) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m max_l = 0 max_l 0 min_r = n min_r n ans = n ans n for i in range(m):
  l, r = map(int, input().split())
  if ans != 0:
    if l <= min_r or r <= max_l:
      max_l = max(max_l, l)
      min_r = min(min_r, r)
    else:
      ans = 0 i range(m) range m l, r = map(int, input().split()) l map(int, input().split()) map int input().split() ().split () input split r if ans != 0:
    if l <= min_r or r <= max_l:
      max_l = max(max_l, l)
      min_r = min(min_r, r)
    else:
      ans = 0 ans != 0 ans 0 if l <= min_r or r <= max_l:
      max_l = max(max_l, l)
      min_r = min(min_r, r)
    else:
      ans = 0 l <= min_r or r <= max_l l <= min_r l min_r r <= max_l r max_l max_l = max(max_l, l) max_l max(max_l, l) max max_l l min_r = min(min_r, r) min_r min(min_r, r) min min_r r ans = 0 ans 0 if ans != 0:
  ans = min_r - max_l + 1 ans != 0 ans 0 ans = min_r - max_l + 1 ans min_r - max_l + 1 min_r - max_l min_r max_l 1 print(ans) print ans m = map(int, input().split()) map(int, input().split()) m max_l = 0 0 max_l ans = 0 0 ans ans = min_r - max_l + 1 min_r - max_l + 1 ans l, r = map(int, input().split()) map(int, input().split()) l r = map(int, input().split()) map(int, input().split()) r n, m = map(int, input().split()) map(int, input().split()) n ans = n n ans min_r = min(min_r, r) min(min_r, r) min_r min_r = n n min_r max_l = max(max_l, l) max(max_l, l) max_l
n, m = map(int, input().split())
max_l = 0
min_r = n
ans = n
for i in range(m):
  l, r = map(int, input().split())
  if ans != 0:
    if l <= min_r or r <= max_l:
      max_l = max(max_l, l)
      min_r = min(min_r, r)
    else:
      ans = 0
if ans != 0:
  ans = min_r - max_l + 1
print(ans)