n,m=map(int,input().split())
c=list()

for i in range(m):
    c.append(list(map(int,input().split())))

s=(list(map(lambda x:x[0],c)))
b=(list(map(lambda x:x[1],c)))

maxs=max(s)
minb=min(b)

if minb<maxs:
    print('0')
else:
    ans=minb-maxs+1
    print(ans) n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m c=list() c list() list for i in range(m):
    c.append(list(map(int,input().split()))) i range(m) range m c.append(list(map(int,input().split()))) c.append c append list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split s=(list(map(lambda x:x[0],c))) s list(map(lambda x:x[0],c)) list map(lambda x:x[0],c) map lambda x:x[0] x[0] x 0 x c b=(list(map(lambda x:x[1],c))) b list(map(lambda x:x[1],c)) list map(lambda x:x[1],c) map lambda x:x[1] x[1] x 1 x c maxs=max(s) maxs max(s) max s minb=min(b) minb min(b) min b if minb<maxs:
    print('0')
else:
    ans=minb-maxs+1
    print(ans) minb<maxs minb maxs print('0') print '0' ans=minb-maxs+1 ans minb-maxs+1 minb-maxs minb maxs 1 print(ans) print ans b=(list(map(lambda x:x[1],c))) list(map(lambda x:x[1],c)) b minb=min(b) min(b) minb m=map(int,input().split()) map(int,input().split()) m ans=minb-maxs+1 minb-maxs+1 ans c=list() list() c s=(list(map(lambda x:x[0],c))) list(map(lambda x:x[0],c)) s n,m=map(int,input().split()) map(int,input().split()) n maxs=max(s) max(s) maxs
n,m=map(int,input().split())
c=list()

for i in range(m):
    c.append(list(map(int,input().split())))

s=(list(map(lambda x:x[0],c)))
b=(list(map(lambda x:x[1],c)))

maxs=max(s)
minb=min(b)

if minb<maxs:
    print('0')
else:
    ans=minb-maxs+1
    print(ans)