N,M=map(int,input().split())
L=[list(map(int,input().split()))for i in range(M)]
r=N
l=0
for i in range(M):
    l=max(l,L[i][0])
    r=min(r,L[i][1])
if r-l+1<0:
    print(0)
else:
    print(r-l+1) N,M=map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M list(map(int,input().split()))for i in range(M) for i in range(M) i range(M) range M for i in range(M) list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split L=[list(map(int,input().split()))for i in range(M)] L [list(map(int,input().split()))for i in range(M)] r=N r N l=0 l 0 for i in range(M):
    l=max(l,L[i][0])
    r=min(r,L[i][1]) i range(M) range M l=max(l,L[i][0]) l max(l,L[i][0]) max l L[i][0] [i] L i 0 r=min(r,L[i][1]) r min(r,L[i][1]) min r L[i][1] [i] L i 1 if r-l+1<0:
    print(0)
else:
    print(r-l+1) r-l+1<0 r-l+1 r-l r l 1 0 print(0) print 0 print(r-l+1) print r-l+1 r-l r l 1 l=0 0 l r=min(r,L[i][1]) min(r,L[i][1]) r M=map(int,input().split()) map(int,input().split()) M r=N N r l=max(l,L[i][0]) max(l,L[i][0]) l L=[list(map(int,input().split()))for i in range(M)] [list(map(int,input().split()))for i in range(M)] L N,M=map(int,input().split()) map(int,input().split()) N
N,M=map(int,input().split())
L=[list(map(int,input().split()))for i in range(M)]
r=N
l=0
for i in range(M):
    l=max(l,L[i][0])
    r=min(r,L[i][1])
if r-l+1<0:
    print(0)
else:
    print(r-l+1)