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

# 共通部分を求め、共通部分が無ければ0を出力する
m = max(L)
M = min(R)
if M >= m: print(M-m+1)
else: print(0) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M L, R = [], [] L [] R [] for _ in range(M):
  l, r = map(int, input().split())
  L.append(l)
  R.append(r)

# 共通部分を求め、共通部分が無ければ0を出力する _ 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 m = max(L) m max(L) max L M = min(R) M min(R) min R if M >= m: print(M-m+1)
else: print(0) M >= m M m m = max(L) max(L) m N, M = map(int, input().split()) map(int, input().split()) N L, R = [], [] [] L M = min(R) min(R) M r = map(int, input().split()) map(int, input().split()) r l, r = map(int, input().split()) map(int, input().split()) l R = [], [] [] R M = map(int, input().split()) map(int, input().split()) M
N, M = map(int, input().split())
L, R = [], []
for _ in range(M):
  l, r = map(int, input().split())
  L.append(l)
  R.append(r)

# 共通部分を求め、共通部分が無ければ0を出力する
m = max(L)
M = min(R)
if M >= m: print(M-m+1)
else: print(0)