N,T = map(int,input().split())
X = [list(map(int,input().split())) for n in range(T)]
M = N
m = 0

for a,b in X:
  M = min(M,b)
  m = max(m,a)
  
if M<m:
  print(0)
else:
  print(M-m+1) N,T = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split T list(map(int,input().split())) for n in range(T) for n in range(T) n range(T) range T for n in range(T) list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split X = [list(map(int,input().split())) for n in range(T)] X [list(map(int,input().split())) for n in range(T)] M = N M N m = 0 m 0 for a,b in X:
  M = min(M,b)
  m = max(m,a)
   a b X M = min(M,b) M min(M,b) min M b m = max(m,a) m max(m,a) max m a if M<m:
  print(0)
else:
  print(M-m+1) M<m M m print(0) print 0 print(M-m+1) print M-m+1 M-m M m 1 m = 0 0 m X = [list(map(int,input().split())) for n in range(T)] [list(map(int,input().split())) for n in range(T)] X M = N N M M = min(M,b) min(M,b) M m = max(m,a) max(m,a) m T = map(int,input().split()) map(int,input().split()) T N,T = map(int,input().split()) map(int,input().split()) N
N,T = map(int,input().split())
X = [list(map(int,input().split())) for n in range(T)]
M = N
m = 0

for a,b in X:
  M = min(M,b)
  m = max(m,a)
  
if M<m:
  print(0)
else:
  print(M-m+1)