import numpy as np
N,M = map(int,input().split())
A = (N+2)*[0]

for m in range(M):
  L,R = map(int,input().split())
  A[L]+=1
  A[R+1]-=1

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

for m in range(M):
  L,R = map(int,input().split())
  A[L]+=1
  A[R+1]-=1

A = np.cumsum(A)
print(sum(a==M for a in A))