N,M = map(int,input().split())
L = [0 for _ in range(N)]
for i in range(M):
  l,r = map(int,input().split())
  l-=1;r-=1 #0index
  L[l] += 1
  if r+1 < N:
    L[r+1] -= 1
S = [0]
for i in range(N):
  temp = L[i] + S[-1]
  S.append(temp)
#print(S)
ans = 0
for i in range(1,N+1):
  if S[i] == M:
    ans += 1
print(ans) N,M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M 0 for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) 0 L = [0 for _ in range(N)] L [0 for _ in range(N)] for i in range(M):
  l,r = map(int,input().split())
  l-=1;r-=1 #0index
  L[l] += 1
  if r+1 < N:
    L[r+1] -= 1 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-=1 l 1 r-=1 r 1 L[l] += 1 L[l] L l 1 if r+1 < N:
    L[r+1] -= 1 r+1 < N r+1 r 1 N L[r+1] -= 1 L[r+1] L r+1 r 1 1 S = [0] S [0] 0 for i in range(N):
  temp = L[i] + S[-1]
  S.append(temp)
#print(S) i range(N) range N temp = L[i] + S[-1] temp L[i] + S[-1] L[i] L i S[-1] S -1 S.append(temp) S.append S append temp ans = 0 ans 0 for i in range(1,N+1):
  if S[i] == M:
    ans += 1 i range(1,N+1) range 1 N+1 N 1 if S[i] == M:
    ans += 1 S[i] == M S[i] S i M ans += 1 ans 1 print(ans) print ans S = [0] [0] S N,M = map(int,input().split()) map(int,input().split()) N M = map(int,input().split()) map(int,input().split()) M L = [0 for _ in range(N)] [0 for _ in range(N)] L l,r = map(int,input().split()) map(int,input().split()) l r = map(int,input().split()) map(int,input().split()) r ans += 1 1 ans l-=1 1 l ans = 0 0 ans r-=1 1 r temp = L[i] + S[-1] L[i] + S[-1] temp
N,M = map(int,input().split())
L = [0 for _ in range(N)]
for i in range(M):
  l,r = map(int,input().split())
  l-=1;r-=1 #0index
  L[l] += 1
  if r+1 < N:
    L[r+1] -= 1
S = [0]
for i in range(N):
  temp = L[i] + S[-1]
  S.append(temp)
#print(S)
ans = 0
for i in range(1,N+1):
  if S[i] == M:
    ans += 1
print(ans)