n, m = map(int, input().split())
min_id = 0
max_id = 10**9
for _ in range(m):
    l, r = map(int, input().split())
    min_id = max(l, min_id)
    max_id = min(r, max_id)

ans = max_id - min_id + 1
if ans <= 0:
    print(0)
else:
    print(ans) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m min_id = 0 min_id 0 max_id = 10**9 max_id 10**9 10 9 for _ in range(m):
    l, r = map(int, input().split())
    min_id = max(l, min_id)
    max_id = min(r, max_id) _ range(m) range m l, r = map(int, input().split()) l map(int, input().split()) map int input().split() ().split () input split r min_id = max(l, min_id) min_id max(l, min_id) max l min_id max_id = min(r, max_id) max_id min(r, max_id) min r max_id ans = max_id - min_id + 1 ans max_id - min_id + 1 max_id - min_id max_id min_id 1 if ans <= 0:
    print(0)
else:
    print(ans) ans <= 0 ans 0 print(0) print 0 print(ans) print ans min_id = 0 0 min_id l, r = map(int, input().split()) map(int, input().split()) l max_id = min(r, max_id) min(r, max_id) max_id ans = max_id - min_id + 1 max_id - min_id + 1 ans r = map(int, input().split()) map(int, input().split()) r min_id = max(l, min_id) max(l, min_id) min_id n, m = map(int, input().split()) map(int, input().split()) n max_id = 10**9 10**9 max_id m = map(int, input().split()) map(int, input().split()) m
n, m = map(int, input().split())
min_id = 0
max_id = 10**9
for _ in range(m):
    l, r = map(int, input().split())
    min_id = max(l, min_id)
    max_id = min(r, max_id)

ans = max_id - min_id + 1
if ans <= 0:
    print(0)
else:
    print(ans)