N,M=map(int,input().split())
s=[list(map(int,input().split())) for x in range(M)]

max_left=0
min_right=N

for i in range(M):
    if s[i][0]>max_left:
        max_left=s[i][0]
    if s[i][1]<min_right:
        min_right=s[i][1]
        
cnt=0
for j in range(max_left,min_right+1):
    cnt+=1
print(cnt) 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 x in range(M) for x in range(M) x range(M) range M for x in range(M) list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split s=[list(map(int,input().split())) for x in range(M)] s [list(map(int,input().split())) for x in range(M)] max_left=0 max_left 0 min_right=N min_right N for i in range(M):
    if s[i][0]>max_left:
        max_left=s[i][0]
    if s[i][1]<min_right:
        min_right=s[i][1]
         i range(M) range M if s[i][0]>max_left:
        max_left=s[i][0]
     s[i][0]>max_left s[i][0] [i] s i 0 max_left max_left=s[i][0] max_left s[i][0] [i] s i 0 if s[i][1]<min_right:
        min_right=s[i][1]
         s[i][1]<min_right s[i][1] [i] s i 1 min_right min_right=s[i][1] min_right s[i][1] [i] s i 1 cnt=0 cnt 0 for j in range(max_left,min_right+1):
    cnt+=1 j range(max_left,min_right+1) range max_left min_right+1 min_right 1 cnt+=1 cnt 1 print(cnt) print cnt N,M=map(int,input().split()) map(int,input().split()) N cnt+=1 1 cnt M=map(int,input().split()) map(int,input().split()) M cnt=0 0 cnt min_right=s[i][1] s[i][1] min_right max_left=0 0 max_left min_right=N N min_right s=[list(map(int,input().split())) for x in range(M)] [list(map(int,input().split())) for x in range(M)] s max_left=s[i][0] s[i][0] max_left
N,M=map(int,input().split())
s=[list(map(int,input().split())) for x in range(M)]

max_left=0
min_right=N

for i in range(M):
    if s[i][0]>max_left:
        max_left=s[i][0]
    if s[i][1]<min_right:
        min_right=s[i][1]
        
cnt=0
for j in range(max_left,min_right+1):
    cnt+=1
print(cnt)