n, m, *lr = list(map(int, open(0).read().split()))
print(max(0, min(lr[1::2]) - max(lr[::2]) + 1)) n, m, *lr = list(map(int, open(0).read().split())) n list(map(int, open(0).read().split())) list map(int, open(0).read().split()) map int open(0).read().split() (0).read().split (0).read() (0).read (0) open 0 read split m *lr lr print(max(0, min(lr[1::2]) - max(lr[::2]) + 1)) print max(0, min(lr[1::2]) - max(lr[::2]) + 1) max 0 min(lr[1::2]) - max(lr[::2]) + 1 min(lr[1::2]) - max(lr[::2]) min(lr[1::2]) min lr[1::2] lr 1::2 1 2 max(lr[::2]) max lr[::2] lr ::2 2 1 n, m, *lr = list(map(int, open(0).read().split())) list(map(int, open(0).read().split())) n m, *lr = list(map(int, open(0).read().split())) list(map(int, open(0).read().split())) m
n, m, *lr = list(map(int, open(0).read().split()))
print(max(0, min(lr[1::2]) - max(lr[::2]) + 1))
