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

x = max(l)
y = min(r)

p = 0
for i in range(1,n+1):
    if x <= i and i <= y:
        p += 1

print(p) n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m list(map(int,input().split())) for i in range(m) for i in range(m) i range(m) range m for i in range(m) list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split k = [list(map(int,input().split())) for i in range(m)] k [list(map(int,input().split())) for i in range(m)] list(i) for i in zip(*k) for i in zip(*k) i zip(*k) zip *k k for i in zip(*k) list(i) list i l,r = [list(i) for i in zip(*k)] l [list(i) for i in zip(*k)] r x = max(l) x max(l) max l y = min(r) y min(r) min r p = 0 p 0 for i in range(1,n+1):
    if x <= i and i <= y:
        p += 1 i range(1,n+1) range 1 n+1 n 1 if x <= i and i <= y:
        p += 1 x <= i and i <= y x <= i x i i <= y i y p += 1 p 1 print(p) print p x = max(l) max(l) x k = [list(map(int,input().split())) for i in range(m)] [list(map(int,input().split())) for i in range(m)] k r = [list(i) for i in zip(*k)] [list(i) for i in zip(*k)] r p += 1 1 p y = min(r) min(r) y p = 0 0 p l,r = [list(i) for i in zip(*k)] [list(i) for i in zip(*k)] l m = map(int,input().split()) map(int,input().split()) m n,m = map(int,input().split()) map(int,input().split()) n
n,m = map(int,input().split())
k = [list(map(int,input().split())) for i in range(m)]
l,r = [list(i) for i in zip(*k)]

x = max(l)
y = min(r)

p = 0
for i in range(1,n+1):
    if x <= i and i <= y:
        p += 1

print(p)