N, M = map(int, input().split())
id = [0] * N
ans = 0
for _ in range(M):
  L, R = map(int, input().split())
  id[L-1] += 1
  if R != N:
    id[R] -= 1
for i in range(N):
  if i != 0:
    id[i] += id[i-1]
  if id[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 id = [0] * N id [0] * N [0] 0 N ans = 0 ans 0 for _ in range(M):
  L, R = map(int, input().split())
  id[L-1] += 1
  if R != N:
    id[R] -= 1 _ range(M) range M L, R = map(int, input().split()) L map(int, input().split()) map int input().split() ().split () input split R id[L-1] += 1 id[L-1] id L-1 L 1 1 if R != N:
    id[R] -= 1 R != N R N id[R] -= 1 id[R] id R 1 for i in range(N):
  if i != 0:
    id[i] += id[i-1]
  if id[i] == M:
    ans += 1 i range(N) range N if i != 0:
    id[i] += id[i-1]
   i != 0 i 0 id[i] += id[i-1] id[i] id i id[i-1] id i-1 i 1 if id[i] == M:
    ans += 1 id[i] == M id[i] id i M ans += 1 ans 1 print(ans) print ans M = map(int, input().split()) map(int, input().split()) M ans += 1 1 ans id = [0] * N [0] * N id R = map(int, input().split()) map(int, input().split()) R ans = 0 0 ans L, R = map(int, input().split()) map(int, input().split()) L N, M = map(int, input().split()) map(int, input().split()) N
N, M = map(int, input().split())
id = [0] * N
ans = 0
for _ in range(M):
  L, R = map(int, input().split())
  id[L-1] += 1
  if R != N:
    id[R] -= 1
for i in range(N):
  if i != 0:
    id[i] += id[i-1]
  if id[i] == M:
    ans += 1
print(ans)