n,m = map(int,input().split())
min = 1
max = n

for i in range(m):
    l,r = map(int,input().split()) 
    if min<l: min=l
    if max>r: max=r 

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

for i in range(m):
    l,r = map(int,input().split()) 
    if min<l: min=l
    if max>r: max=r 

if min>max:
    print(0)
else:
    print(max-min+1)
