n, m = map(int, input().split())
lr = [tuple(map(int, input().split())) for _ in range(m)]
l = 1
r = n
for i, j in lr:
    l = max(i, l)
    r = min(j, r)
print(max(r-l+1, 0)) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m tuple(map(int, input().split())) for _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) tuple(map(int, input().split())) tuple map(int, input().split()) map int input().split() ().split () input split lr = [tuple(map(int, input().split())) for _ in range(m)] lr [tuple(map(int, input().split())) for _ in range(m)] l = 1 l 1 r = n r n for i, j in lr:
    l = max(i, l)
    r = min(j, r) i j lr l = max(i, l) l max(i, l) max i l r = min(j, r) r min(j, r) min j r print(max(r-l+1, 0)) print max(r-l+1, 0) max r-l+1 r-l r l 1 0 n, m = map(int, input().split()) map(int, input().split()) n l = 1 1 l r = min(j, r) min(j, r) r m = map(int, input().split()) map(int, input().split()) m lr = [tuple(map(int, input().split())) for _ in range(m)] [tuple(map(int, input().split())) for _ in range(m)] lr l = max(i, l) max(i, l) l r = n n r
n, m = map(int, input().split())
lr = [tuple(map(int, input().split())) for _ in range(m)]
l = 1
r = n
for i, j in lr:
    l = max(i, l)
    r = min(j, r)
print(max(r-l+1, 0))
