N, M = map(int, input().split())
x = [0] * (N + 1)

for i in range(M):
  l, r = map(int, input().split())
  x[l - 1] += 1
  x[r] -= 1
  
for i in range(1, N + 1):
  x[i] += x[i - 1]
  
#print(x)
print(x.count(M)) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M x = [0] * (N + 1) x [0] * (N + 1) [0] 0 N + 1 N 1 for i in range(M):
  l, r = map(int, input().split())
  x[l - 1] += 1
  x[r] -= 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 x[l - 1] += 1 x[l - 1] x l - 1 l 1 1 x[r] -= 1 x[r] x r 1 for i in range(1, N + 1):
  x[i] += x[i - 1]
  
#print(x) i range(1, N + 1) range 1 N + 1 N 1 x[i] += x[i - 1] x[i] x i x[i - 1] x i - 1 i 1 print(x.count(M)) print x.count(M) x.count x count M M = map(int, input().split()) map(int, input().split()) M x = [0] * (N + 1) [0] * (N + 1) x l, r = map(int, input().split()) map(int, input().split()) l r = map(int, input().split()) map(int, input().split()) r N, M = map(int, input().split()) map(int, input().split()) N
N, M = map(int, input().split())
x = [0] * (N + 1)

for i in range(M):
  l, r = map(int, input().split())
  x[l - 1] += 1
  x[r] -= 1
  
for i in range(1, N + 1):
  x[i] += x[i - 1]
  
#print(x)
print(x.count(M))