g=lambda:map(int,input().split())
_,m=g()
ml,mr=0,10**5
for _ in range(m):
    l,r=g()
    ml=max(ml,l)
    mr=min(mr,r)
print([0,mr-ml+1][mr>=ml]) g=lambda:map(int,input().split()) g lambda:map(int,input().split()) map(int,input().split()) map int input().split() ().split () input split _,m=g() _ g() g m ml,mr=0,10**5 ml 0 mr 10**5 10 5 for _ in range(m):
    l,r=g()
    ml=max(ml,l)
    mr=min(mr,r) _ range(m) range m l,r=g() l g() g r ml=max(ml,l) ml max(ml,l) max ml l mr=min(mr,r) mr min(mr,r) min mr r print([0,mr-ml+1][mr>=ml]) print [0,mr-ml+1][mr>=ml] [0,mr-ml+1] 0 mr-ml+1 mr-ml mr ml 1 mr>=ml mr ml mr=0,10**5 10**5 mr r=g() g() r l,r=g() g() l _,m=g() g() _ g=lambda:map(int,input().split()) lambda:map(int,input().split()) g ml=max(ml,l) max(ml,l) ml mr=min(mr,r) min(mr,r) mr m=g() g() m ml,mr=0,10**5 0 ml
g=lambda:map(int,input().split())
_,m=g()
ml,mr=0,10**5
for _ in range(m):
    l,r=g()
    ml=max(ml,l)
    mr=min(mr,r)
print([0,mr-ml+1][mr>=ml])
