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

L,R = list(zip(*LR))#転置
#print(L)
#print(R)
print(max(min(R)-max(L)+1,0))
 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 _ in range(M) for _ in range(M) _ range(M) range M for _ in range(M) list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split LR = [list(map(int,input().split()))for _ in range(M)] LR [list(map(int,input().split()))for _ in range(M)] L,R = list(zip(*LR)) L list(zip(*LR)) list zip(*LR) zip *LR LR R print(max(min(R)-max(L)+1,0)) print max(min(R)-max(L)+1,0) max min(R)-max(L)+1 min(R)-max(L) min(R) min R max(L) max L 1 0 LR = [list(map(int,input().split()))for _ in range(M)] [list(map(int,input().split()))for _ in range(M)] LR N,M = map(int,input().split()) map(int,input().split()) N M = map(int,input().split()) map(int,input().split()) M L,R = list(zip(*LR)) list(zip(*LR)) L R = list(zip(*LR)) list(zip(*LR)) R
N,M = map(int,input().split())
LR = [list(map(int,input().split()))for _ in range(M)]

L,R = list(zip(*LR))#転置
#print(L)
#print(R)
print(max(min(R)-max(L)+1,0))

