import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())


N,M = MI()
A = [0]*(N+2)

for i in range(M):
    l,r = MI()
    A[l] += 1
    A[r+1] -= 1

from itertools import accumulate

A = list(accumulate(A))
print(sum(A[i] == M for i in range(1,N+1))) import sys sys def MI(): return map(int,sys.stdin.readline().rstrip().split()) MI N,M = MI() N MI() MI M A = [0]*(N+2) A [0]*(N+2) [0] 0 N+2 N 2 for i in range(M):
    l,r = MI()
    A[l] += 1
    A[r+1] -= 1 i range(M) range M l,r = MI() l MI() MI r A[l] += 1 A[l] A l 1 A[r+1] -= 1 A[r+1] A r+1 r 1 1 from itertools import accumulate A = list(accumulate(A)) A list(accumulate(A)) list accumulate(A) accumulate A print(sum(A[i] == M for i in range(1,N+1))) print sum(A[i] == M for i in range(1,N+1)) sum A[i] == M A[i] A i M def MI(): return map(int,sys.stdin.readline().rstrip().split()) def MI(): return map(int,sys.stdin.readline().rstrip().split()) MI A = list(accumulate(A)) list(accumulate(A)) A r = MI() MI() r l,r = MI() MI() l N,M = MI() MI() N A = [0]*(N+2) [0]*(N+2) A M = MI() MI() M
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())


N,M = MI()
A = [0]*(N+2)

for i in range(M):
    l,r = MI()
    A[l] += 1
    A[r+1] -= 1

from itertools import accumulate

A = list(accumulate(A))
print(sum(A[i] == M for i in range(1,N+1)))
