n,m=map(int,input().split())
a=[]
b=[]
for i in range(m):
    l,r=map(int,input().split())
    a.append(l)
    b.append(r)
x=max(a)
y=min(b)

if y-x<0:
    print('0')
else:
    print(y-x+1) n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m a=[] a [] b=[] b [] for i in range(m):
    l,r=map(int,input().split())
    a.append(l)
    b.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 a.append(l) a.append a append l b.append(r) b.append b append r x=max(a) x max(a) max a y=min(b) y min(b) min b if y-x<0:
    print('0')
else:
    print(y-x+1) y-x<0 y-x y x 0 print('0') print '0' print(y-x+1) print y-x+1 y-x y x 1 m=map(int,input().split()) map(int,input().split()) m b=[] [] b x=max(a) max(a) x n,m=map(int,input().split()) map(int,input().split()) n y=min(b) min(b) y l,r=map(int,input().split()) map(int,input().split()) l r=map(int,input().split()) map(int,input().split()) r a=[] [] a
n,m=map(int,input().split())
a=[]
b=[]
for i in range(m):
    l,r=map(int,input().split())
    a.append(l)
    b.append(r)
x=max(a)
y=min(b)

if y-x<0:
    print('0')
else:
    print(y-x+1)