N,M = map(int, input().split())
L = [0]*M
R = [0]*M

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

L_SORT = sorted(L)
R_SORT = sorted(R)

#print(L_SORT)
#print(R_SORT)

L_MAX = L_SORT[M-1]
R_MIN = R_SORT[0]

#print(L_MAX)
#print(R_MIN)


if (R_MIN - L_MAX) < 0:
  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 = [0]*M L [0]*M [0] 0 M R = [0]*M R [0]*M [0] 0 M for i in range (M):
  L[i],R[i] = map(int, input().split()) i range (M) range M L[i],R[i] = map(int, input().split()) L[i] L i map(int, input().split()) map int input().split() ().split () input split R[i] R i L_SORT = sorted(L) L_SORT sorted(L) sorted L R_SORT = sorted(R) R_SORT sorted(R) sorted R L_MAX = L_SORT[M-1] L_MAX L_SORT[M-1] L_SORT M-1 M 1 R_MIN = R_SORT[0] R_MIN R_SORT[0] R_SORT 0 if (R_MIN - L_MAX) < 0:
  print(0)
else:
  print(R_MIN-L_MAX + 1) (R_MIN - L_MAX) < 0 R_MIN - L_MAX R_MIN L_MAX 0 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 N,M = map(int, input().split()) map(int, input().split()) N L_SORT = sorted(L) sorted(L) L_SORT R_MIN = R_SORT[0] R_SORT[0] R_MIN L = [0]*M [0]*M L R = [0]*M [0]*M R M = map(int, input().split()) map(int, input().split()) M L_MAX = L_SORT[M-1] L_SORT[M-1] L_MAX R_SORT = sorted(R) sorted(R) R_SORT
N,M = map(int, input().split())
L = [0]*M
R = [0]*M

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

L_SORT = sorted(L)
R_SORT = sorted(R)

#print(L_SORT)
#print(R_SORT)

L_MAX = L_SORT[M-1]
R_MIN = R_SORT[0]

#print(L_MAX)
#print(R_MIN)


if (R_MIN - L_MAX) < 0:
  print(0)
else:
  print(R_MIN-L_MAX + 1)