n, m = map(int, input().split())
max_l = 0
min_r = 10**5
for i in range(m):
  l, r = map(int, input().split())
  if l > max_l:
    max_l = l
  if r < min_r:
    min_r = r
res = min_r - max_l + 1
if res<0:
  res = 0
print(res) 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 = 10**5 min_r 10**5 10 5 for i in range(m):
  l, r = map(int, input().split())
  if l > max_l:
    max_l = l
  if r < min_r:
    min_r = r 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 l > max_l:
    max_l = l
   l > max_l l max_l max_l = l max_l l if r < min_r:
    min_r = r r < min_r r min_r min_r = r min_r r res = min_r - max_l + 1 res min_r - max_l + 1 min_r - max_l min_r max_l 1 if res<0:
  res = 0 res<0 res 0 res = 0 res 0 print(res) print res min_r = r r min_r l, r = map(int, input().split()) map(int, input().split()) l r = map(int, input().split()) map(int, input().split()) r max_l = 0 0 max_l max_l = l l max_l res = 0 0 res m = map(int, input().split()) map(int, input().split()) m res = min_r - max_l + 1 min_r - max_l + 1 res n, m = map(int, input().split()) map(int, input().split()) n min_r = 10**5 10**5 min_r
n, m = map(int, input().split())
max_l = 0
min_r = 10**5
for i in range(m):
  l, r = map(int, input().split())
  if l > max_l:
    max_l = l
  if r < min_r:
    min_r = r
res = min_r - max_l + 1
if res<0:
  res = 0
print(res)
