n,m=map(int,input().split())
s=0
t=10**10
for i in range(m):
  l,r=map(int,input().split())
  s=max(s,l)
  t=min(t,r)

if s>t:
  print(0)
else:
  print(t-s+1) n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m s=0 s 0 t=10**10 t 10**10 10 10 for i in range(m):
  l,r=map(int,input().split())
  s=max(s,l)
  t=min(t,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 s=max(s,l) s max(s,l) max s l t=min(t,r) t min(t,r) min t r if s>t:
  print(0)
else:
  print(t-s+1) s>t s t print(0) print 0 print(t-s+1) print t-s+1 t-s t s 1 s=max(s,l) max(s,l) s m=map(int,input().split()) map(int,input().split()) m t=10**10 10**10 t n,m=map(int,input().split()) map(int,input().split()) n l,r=map(int,input().split()) map(int,input().split()) l t=min(t,r) min(t,r) t s=0 0 s r=map(int,input().split()) map(int,input().split()) r
n,m=map(int,input().split())
s=0
t=10**10
for i in range(m):
  l,r=map(int,input().split())
  s=max(s,l)
  t=min(t,r)

if s>t:
  print(0)
else:
  print(t-s+1)