N, M = map(int,input().split())
a = []
b = []
for i in range(M):
    L, R = map(int,input().split())
    a.append(L)
    b.append(R)
a = sorted(a)
b = sorted(b)
A = a[M - 1]
B = b[0]
if A <= B:
    print(B - A + 1)
else:
    print(0) N, M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M a = [] a [] b = [] b [] for i in range(M):
    L, R = map(int,input().split())
    a.append(L)
    b.append(R) i range(M) range M L, R = map(int,input().split()) L map(int,input().split()) map int input().split() ().split () input split R a.append(L) a.append a append L b.append(R) b.append b append R a = sorted(a) a sorted(a) sorted a b = sorted(b) b sorted(b) sorted b A = a[M - 1] A a[M - 1] a M - 1 M 1 B = b[0] B b[0] b 0 if A <= B:
    print(B - A + 1)
else:
    print(0) A <= B A B print(B - A + 1) print B - A + 1 B - A B A 1 print(0) print 0 a = sorted(a) sorted(a) a L, R = map(int,input().split()) map(int,input().split()) L b = sorted(b) sorted(b) b B = b[0] b[0] B N, M = map(int,input().split()) map(int,input().split()) N b = [] [] b R = map(int,input().split()) map(int,input().split()) R M = map(int,input().split()) map(int,input().split()) M a = [] [] a A = a[M - 1] a[M - 1] A
N, M = map(int,input().split())
a = []
b = []
for i in range(M):
    L, R = map(int,input().split())
    a.append(L)
    b.append(R)
a = sorted(a)
b = sorted(b)
A = a[M - 1]
B = b[0]
if A <= B:
    print(B - A + 1)
else:
    print(0)