import numpy as np

N,M = list(map(int,input().split()))

A = (N+2)*[0]



for m in range(M):

  L,R = list(map(int,input().split()))

  A[L]+=1

  A[R+1]-=1



A = np.cumsum(A)

print((sum(a==M for a in A)))
N,M = list(map(int,input().split()))

L = []

R = []



for m in range(M):

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

  L+=[l]

  R+=[r]



print((max(0,min(R)-max(L)+1)))
import numpy as np

N, M = list(map(int, input().split()))
A = (N + 2) * [0]
for m in range(M):
    L, R = list(map(int, input().split()))
    A[L] += 1
    A[R + 1] -= 1
A = np.cumsum(A)
print((sum(a == M for a in A)))

N, M = list(map(int, input().split()))
L = []
R = []
for m in range(M):
    l, r = list(map(int, input().split()))
    L += [l]
    R += [r]
print((max(0, min(R) - max(L) + 1)))

-import numpy as np - -A = (N + 2) * [0] +L = [] +R = [] -    L, R = list(map(int, input().split())) -    A[L] += 1 -    A[R + 1] -= 1 -A = np.cumsum(A) -print((sum(a == M for a in A))) +    l, r = list(map(int, input().split())) +    L += [l] +    R += [r] +print((max(0, min(R) - max(L) + 1)))