N,M = map(int,input().split())
L_list = []
R_list = []
for o in range(M):
    L,R = map(int,input().split())
    L_list.append(L)
    R_list.append(R)
L_max = max(L_list)
R_min = min(R_list)
    
if L_max <= R_min:
    ans = R_min - L_max + 1
else:
    ans = 0
print(ans) N,M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M L_list = [] L_list [] R_list = [] R_list [] for o in range(M):
    L,R = map(int,input().split())
    L_list.append(L)
    R_list.append(R) o range(M) range M L,R = map(int,input().split()) L map(int,input().split()) map int input().split() ().split () input split R L_list.append(L) L_list.append L_list append L R_list.append(R) R_list.append R_list append R L_max = max(L_list) L_max max(L_list) max L_list R_min = min(R_list) R_min min(R_list) min R_list if L_max <= R_min:
    ans = R_min - L_max + 1
else:
    ans = 0 L_max <= R_min L_max R_min ans = R_min - L_max + 1 ans R_min - L_max + 1 R_min - L_max R_min L_max 1 ans = 0 ans 0 print(ans) print ans R_min = min(R_list) min(R_list) R_min R_list = [] [] R_list L,R = map(int,input().split()) map(int,input().split()) L ans = R_min - L_max + 1 R_min - L_max + 1 ans R = map(int,input().split()) map(int,input().split()) R L_list = [] [] L_list L_max = max(L_list) max(L_list) L_max N,M = map(int,input().split()) map(int,input().split()) N ans = 0 0 ans M = map(int,input().split()) map(int,input().split()) M
N,M = map(int,input().split())
L_list = []
R_list = []
for o in range(M):
    L,R = map(int,input().split())
    L_list.append(L)
    R_list.append(R)
L_max = max(L_list)
R_min = min(R_list)
    
if L_max <= R_min:
    ans = R_min - L_max + 1
else:
    ans = 0
print(ans)