N, M = map(int, input().split())

L = []

for i in range(M):
    LR = list(map(int, input().split()))
    L.append(LR)

res = [L[0][0], L[0][1]]

for i in range(M):
    res = [max(res[0], L[i][0]), min(res[1], L[i][1])]

if res[1] < res[0]:
    print(0)
else: 
    print(res[1] - res[0] + 1) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M L = [] L [] for i in range(M):
    LR = list(map(int, input().split()))
    L.append(LR) i range(M) range M LR = list(map(int, input().split())) LR list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split L.append(LR) L.append L append LR res = [L[0][0], L[0][1]] res [L[0][0], L[0][1]] L[0][0] [0] L 0 0 L[0][1] [0] L 0 1 for i in range(M):
    res = [max(res[0], L[i][0]), min(res[1], L[i][1])] i range(M) range M res = [max(res[0], L[i][0]), min(res[1], L[i][1])] res [max(res[0], L[i][0]), min(res[1], L[i][1])] max(res[0], L[i][0]) max res[0] res 0 L[i][0] [i] L i 0 min(res[1], L[i][1]) min res[1] res 1 L[i][1] [i] L i 1 if res[1] < res[0]:
    print(0)
else: 
    print(res[1] - res[0] + 1) res[1] < res[0] res[1] res 1 res[0] res 0 print(0) print 0 print(res[1] - res[0] + 1) print res[1] - res[0] + 1 res[1] - res[0] res[1] res 1 res[0] res 0 1 L = [] [] L N, M = map(int, input().split()) map(int, input().split()) N M = map(int, input().split()) map(int, input().split()) M res = [max(res[0], L[i][0]), min(res[1], L[i][1])] [max(res[0], L[i][0]), min(res[1], L[i][1])] res LR = list(map(int, input().split())) list(map(int, input().split())) LR res = [L[0][0], L[0][1]] [L[0][0], L[0][1]] res
N, M = map(int, input().split())

L = []

for i in range(M):
    LR = list(map(int, input().split()))
    L.append(LR)

res = [L[0][0], L[0][1]]

for i in range(M):
    res = [max(res[0], L[i][0]), min(res[1], L[i][1])]

if res[1] < res[0]:
    print(0)
else: 
    print(res[1] - res[0] + 1)