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

l=[0 for i in range(k+1)]

for i in range(m):

  a,s=list(map(int,input().split()))

  l[a-1]+=1;l[s]-=1

ans=0

f=0

for j in range(k):

  l[j]+=f

  f=l[j]

print((len([1 for i in l if i==m])))
n,m=list(map(int,input().split()))

table=[0]*(n+2)

for i in range(m):

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

    table[l]+=1

    table[r+1]-=1

from itertools import accumulate

from collections import Counter as co

var=co((accumulate(table)))



if m not in var:print((0))

else:print((var[m]))





k, m = list(map(int, input().split()))
l = [0 for i in range(k + 1)]
for i in range(m):
    a, s = list(map(int, input().split()))
    l[a - 1] += 1
    l[s] -= 1
ans = 0
f = 0
for j in range(k):
    l[j] += f
    f = l[j]
print((len([1 for i in l if i == m])))

n, m = list(map(int, input().split()))
table = [0] * (n + 2)
for i in range(m):
    l, r = list(map(int, input().split()))
    table[l] += 1
    table[r + 1] -= 1
from itertools import accumulate
from collections import Counter as co

var = co((accumulate(table)))
if m not in var:
    print((0))
else:
    print((var[m]))

-k, m = list(map(int, input().split())) -l = [0 for i in range(k + 1)] +n, m = list(map(int, input().split())) +table = [0] * (n + 2) -    a, s = list(map(int, input().split())) -    l[a - 1] += 1 -    l[s] -= 1 -ans = 0 -f = 0 -for j in range(k): -    l[j] += f -    f = l[j] -print((len([1 for i in l if i == m]))) +    l, r = list(map(int, input().split())) +    table[l] += 1 +    table[r + 1] -= 1 +from itertools import accumulate +from collections import Counter as co + +var = co((accumulate(table))) +if m not in var: +    print((0)) +else: +    print((var[m]))