n, m = map(int, input().split())
l, r = zip(*[map(int, input().split()) for _ in range(m)])

min_r = min(r)
max_l = max(l)

if min_r >= max_l:
    print(min_r - max_l + 1)
else:
    print(0) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m map(int, input().split()) for _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) map(int, input().split()) map int input().split() ().split () input split l, r = zip(*[map(int, input().split()) for _ in range(m)]) l zip(*[map(int, input().split()) for _ in range(m)]) zip *[map(int, input().split()) for _ in range(m)] [map(int, input().split()) for _ in range(m)] r min_r = min(r) min_r min(r) min r max_l = max(l) max_l max(l) max l if min_r >= max_l:
    print(min_r - max_l + 1)
else:
    print(0) min_r >= max_l min_r max_l print(min_r - max_l + 1) print min_r - max_l + 1 min_r - max_l min_r max_l 1 print(0) print 0 min_r = min(r) min(r) min_r l, r = zip(*[map(int, input().split()) for _ in range(m)]) zip(*[map(int, input().split()) for _ in range(m)]) l m = map(int, input().split()) map(int, input().split()) m n, m = map(int, input().split()) map(int, input().split()) n max_l = max(l) max(l) max_l r = zip(*[map(int, input().split()) for _ in range(m)]) zip(*[map(int, input().split()) for _ in range(m)]) r
n, m = map(int, input().split())
l, r = zip(*[map(int, input().split()) for _ in range(m)])

min_r = min(r)
max_l = max(l)

if min_r >= max_l:
    print(min_r - max_l + 1)
else:
    print(0)
