n,m,*t=list(map(int,open(0).read().split()));a,c=[0]*-~n,0

for l,r in zip(t[::2],t[1::2]):a[l-1]+=1;a[r]-=1

for i in range(n):a[i+1]+=a[i];c+=a[i]==m

print(c)
n,m,*t=list(map(int,open(0).read().split()));print((max(0,min(t[1::2])-max(t[::2])+1)))
n, m, *t = list(map(int, open(0).read().split()))
a, c = [0] * -~n, 0
for l, r in zip(t[::2], t[1::2]):
    a[l - 1] += 1
    a[r] -= 1
for i in range(n):
    a[i + 1] += a[i]
    c += a[i] == m
print(c)

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

-a, c = [0] * -~n, 0 -for l, r in zip(t[::2], t[1::2]): -    a[l - 1] += 1 -    a[r] -= 1 -for i in range(n): -    a[i + 1] += a[i] -    c += a[i] == m -print(c) +print((max(0, min(t[1::2]) - max(t[::2]) + 1)))