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

L = list()
R = list()
for i in range(M):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)

maxL = max(L)
minR = min(R)

num = 0 
for j in range(maxL,minR+1):
    num +=1

print(num) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M L = list() L list() list R = list() R list() list for i in range(M):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r) i range(M) range M l, r = map(int, input().split()) l map(int, input().split()) map int input().split() ().split () input split r L.append(l) L.append L append l R.append(r) R.append R append r maxL = max(L) maxL max(L) max L minR = min(R) minR min(R) min R num = 0 num 0 for j in range(maxL,minR+1):
    num +=1 j range(maxL,minR+1) range maxL minR+1 minR 1 num +=1 num 1 print(num) print num L = list() list() L l, r = map(int, input().split()) map(int, input().split()) l num +=1 1 num M = map(int, input().split()) map(int, input().split()) M maxL = max(L) max(L) maxL minR = min(R) min(R) minR r = map(int, input().split()) map(int, input().split()) r N, M = map(int, input().split()) map(int, input().split()) N R = list() list() R num = 0 0 num
N, M = map(int, input().split())

L = list()
R = list()
for i in range(M):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)

maxL = max(L)
minR = min(R)

num = 0 
for j in range(maxL,minR+1):
    num +=1

print(num)