N,M = map(int,input().split())
L=[]
R=[]

for i in range(M):
  l,r = map(int,input().split())
  L.append(l)
  R.append(r)
  
Rm=min(R)
LM=max(L)

if Rm-LM >= 0:
  print(Rm-LM+1)
  
else:
  print(0) N,M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M L=[] L [] R=[] R [] for i in range(M):
  l,r = map(int,input().split())
  L.append(l)
  R.append(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 L.append(l) L.append L append l R.append(r) R.append R append r Rm=min(R) Rm min(R) min R LM=max(L) LM max(L) max L if Rm-LM >= 0:
  print(Rm-LM+1)
  
else:
  print(0) Rm-LM >= 0 Rm-LM Rm LM 0 print(Rm-LM+1) print Rm-LM+1 Rm-LM Rm LM 1 print(0) print 0 N,M = map(int,input().split()) map(int,input().split()) N l,r = map(int,input().split()) map(int,input().split()) l r = map(int,input().split()) map(int,input().split()) r LM=max(L) max(L) LM Rm=min(R) min(R) Rm M = map(int,input().split()) map(int,input().split()) M L=[] [] L R=[] [] R
N,M = map(int,input().split())
L=[]
R=[]

for i in range(M):
  l,r = map(int,input().split())
  L.append(l)
  R.append(r)
  
Rm=min(R)
LM=max(L)

if Rm-LM >= 0:
  print(Rm-LM+1)
  
else:
  print(0)