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

L = []
R = []
for i in range(M):
    l,r = map(int, input().split())
    L.append(l)
    R.append(r)

L_max = max(L)
R_min = min(R)

if L_max > R_min:
    print(0)
else:
    print(R_min-L_max+1) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M L = [] L [] R = [] R [] for i in range(M):
    l,r = map(int, input().split())
    L.append(l)
    R.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 L.append(l) L.append L append l R.append(r) R.append R append r L_max = max(L) L_max max(L) max L R_min = min(R) R_min min(R) min R if L_max > R_min:
    print(0)
else:
    print(R_min-L_max+1) L_max > R_min L_max R_min print(0) print 0 print(R_min-L_max+1) print R_min-L_max+1 R_min-L_max R_min L_max 1 l,r = map(int, input().split()) map(int, input().split()) l M = map(int, input().split()) map(int, input().split()) M R_min = min(R) min(R) R_min L = [] [] L R = [] [] R L_max = max(L) max(L) L_max r = map(int, input().split()) map(int, input().split()) r N, M = map(int, input().split()) map(int, input().split()) N
N, M = map(int, input().split())

L = []
R = []
for i in range(M):
    l,r = map(int, input().split())
    L.append(l)
    R.append(r)

L_max = max(L)
R_min = min(R)

if L_max > R_min:
    print(0)
else:
    print(R_min-L_max+1)
