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

u = 0
o = 10 ** 9
for i in range(M):
    u = max(u, I[i][0])
    o = min(o, I[i][1])

if u > o:
    print(0)
else:
    print(o-u+1) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M I = [] I [] for _ in range(M):
    I.append(list(map(int, input().split()))) _ range(M) range M I.append(list(map(int, input().split()))) I.append I append list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split u = 0 u 0 o = 10 ** 9 o 10 ** 9 10 9 for i in range(M):
    u = max(u, I[i][0])
    o = min(o, I[i][1]) i range(M) range M u = max(u, I[i][0]) u max(u, I[i][0]) max u I[i][0] [i] I i 0 o = min(o, I[i][1]) o min(o, I[i][1]) min o I[i][1] [i] I i 1 if u > o:
    print(0)
else:
    print(o-u+1) u > o u o print(0) print 0 print(o-u+1) print o-u+1 o-u o u 1 I = [] [] I N, M = map(int, input().split()) map(int, input().split()) N u = max(u, I[i][0]) max(u, I[i][0]) u o = min(o, I[i][1]) min(o, I[i][1]) o u = 0 0 u o = 10 ** 9 10 ** 9 o M = map(int, input().split()) map(int, input().split()) M
N, M = map(int, input().split())
I = []
for _ in range(M):
    I.append(list(map(int, input().split())))

u = 0
o = 10 ** 9
for i in range(M):
    u = max(u, I[i][0])
    o = min(o, I[i][1])

if u > o:
    print(0)
else:
    print(o-u+1)