import numpy as np
N,M=map(int,input().strip().split())
LR=np.array([list(map(int,input().strip().split())) for _ in range(M)])
print(max(min(LR[:,1])-max(LR[:,0])+1,0)) import numpy as np numpy N,M=map(int,input().strip().split()) N map(int,input().strip().split()) map int input().strip().split() ().strip().split ().strip() ().strip () input strip split M list(map(int,input().strip().split())) for _ in range(M) for _ in range(M) _ range(M) range M for _ in range(M) list(map(int,input().strip().split())) list map(int,input().strip().split()) map int input().strip().split() ().strip().split ().strip() ().strip () input strip split LR=np.array([list(map(int,input().strip().split())) for _ in range(M)]) LR np.array([list(map(int,input().strip().split())) for _ in range(M)]) np.array np array [list(map(int,input().strip().split())) for _ in range(M)] print(max(min(LR[:,1])-max(LR[:,0])+1,0)) print max(min(LR[:,1])-max(LR[:,0])+1,0) max min(LR[:,1])-max(LR[:,0])+1 min(LR[:,1])-max(LR[:,0]) min(LR[:,1]) min LR[:,1] LR : max(LR[:,0]) max LR[:,0] LR : 1 0 LR=np.array([list(map(int,input().strip().split())) for _ in range(M)]) np.array([list(map(int,input().strip().split())) for _ in range(M)]) LR N,M=map(int,input().strip().split()) map(int,input().strip().split()) N M=map(int,input().strip().split()) map(int,input().strip().split()) M
import numpy as np
N,M=map(int,input().strip().split())
LR=np.array([list(map(int,input().strip().split())) for _ in range(M)])
print(max(min(LR[:,1])-max(LR[:,0])+1,0))