n,m=list(map(int,input().split()))

c=[0]*(n+2)

for i in range(m):

  l,r=list(map(int,input().split()))

  c[l-1]+=1

  c[r]-=1

for i in range(1,n+2):

  c[i]=c[i]+c[i-1]

ans=0

for i in range(n+2):

  if c[i]==m:

    ans+=1

print(ans)
n,m=list(map(int,input().split()))

l,r=list(map(int,input().split()))

for i in range(m-1):

  tl,tr=list(map(int,input().split()))

  if l<tl:

    l=tl

  if tr<r:

    r=tr

print((max(r-l+1,0)))
n, m = list(map(int, input().split()))
c = [0] * (n + 2)
for i in range(m):
    l, r = list(map(int, input().split()))
    c[l - 1] += 1
    c[r] -= 1
for i in range(1, n + 2):
    c[i] = c[i] + c[i - 1]
ans = 0
for i in range(n + 2):
    if c[i] == m:
        ans += 1
print(ans)

n, m = list(map(int, input().split()))
l, r = list(map(int, input().split()))
for i in range(m - 1):
    tl, tr = list(map(int, input().split()))
    if l < tl:
        l = tl
    if tr < r:
        r = tr
print((max(r - l + 1, 0)))

-c = [0] * (n + 2) -for i in range(m): -    l, r = list(map(int, input().split())) -    c[l - 1] += 1 -    c[r] -= 1 -for i in range(1, n + 2): -    c[i] = c[i] + c[i - 1] -ans = 0 -for i in range(n + 2): -    if c[i] == m: -        ans += 1 -print(ans) +l, r = list(map(int, input().split())) +for i in range(m - 1): +    tl, tr = list(map(int, input().split())) +    if l < tl: +        l = tl +    if tr < r: +        r = tr +print((max(r - l + 1, 0)))