n,m = map(int,input().split())
a = []
b = []
for i in range(m):
    A,B = map(int,input().split())
    a.append(A)
    b.append(B)
    
ans = min(b) - max(a) + 1
print(max(ans,0)) 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):
    A,B = map(int,input().split())
    a.append(A)
    b.append(B)
     i range(m) range m A,B = map(int,input().split()) A map(int,input().split()) map int input().split() ().split () input split B a.append(A) a.append a append A b.append(B) b.append b append B ans = min(b) - max(a) + 1 ans min(b) - max(a) + 1 min(b) - max(a) min(b) min b max(a) max a 1 print(max(ans,0)) print max(ans,0) max ans 0 A,B = map(int,input().split()) map(int,input().split()) A n,m = map(int,input().split()) map(int,input().split()) n b = [] [] b ans = min(b) - max(a) + 1 min(b) - max(a) + 1 ans a = [] [] a B = map(int,input().split()) map(int,input().split()) B m = map(int,input().split()) map(int,input().split()) m
n,m = map(int,input().split())
a = []
b = []
for i in range(m):
    A,B = map(int,input().split())
    a.append(A)
    b.append(B)
    
ans = min(b) - max(a) + 1
print(max(ans,0))