[n,m] = [int(i) for i in input().split()]
to_acc = [0] * (n+1)
for i in range(m):
  [l,r] = [int(j)-1 for j in input().split()]
  to_acc[l] += 1
  to_acc[r+1] -= 1
acc = [0]
ans = 0
for i in range(n+1):
  acc.append(acc[-1] + to_acc[i])
for i in range(1,n+1):
  if m == acc[i]:
    ans += 1
print(ans) int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i [n,m] = [int(i) for i in input().split()] [n,m] n m [int(i) for i in input().split()] to_acc = [0] * (n+1) to_acc [0] * (n+1) [0] 0 n+1 n 1 for i in range(m):
  [l,r] = [int(j)-1 for j in input().split()]
  to_acc[l] += 1
  to_acc[r+1] -= 1 i range(m) range m int(j)-1 for j in input().split() for j in input().split() j input().split() ().split () input split for j in input().split() int(j)-1 int(j) int j 1 [l,r] = [int(j)-1 for j in input().split()] [l,r] l r [int(j)-1 for j in input().split()] to_acc[l] += 1 to_acc[l] to_acc l 1 to_acc[r+1] -= 1 to_acc[r+1] to_acc r+1 r 1 1 acc = [0] acc [0] 0 ans = 0 ans 0 for i in range(n+1):
  acc.append(acc[-1] + to_acc[i]) i range(n+1) range n+1 n 1 acc.append(acc[-1] + to_acc[i]) acc.append acc append acc[-1] + to_acc[i] acc[-1] acc -1 to_acc[i] to_acc i for i in range(1,n+1):
  if m == acc[i]:
    ans += 1 i range(1,n+1) range 1 n+1 n 1 if m == acc[i]:
    ans += 1 m == acc[i] m acc[i] acc i ans += 1 ans 1 print(ans) print ans acc = [0] [0] acc ans = 0 0 ans ans += 1 1 ans to_acc = [0] * (n+1) [0] * (n+1) to_acc
[n,m] = [int(i) for i in input().split()]
to_acc = [0] * (n+1)
for i in range(m):
  [l,r] = [int(j)-1 for j in input().split()]
  to_acc[l] += 1
  to_acc[r+1] -= 1
acc = [0]
ans = 0
for i in range(n+1):
  acc.append(acc[-1] + to_acc[i])
for i in range(1,n+1):
  if m == acc[i]:
    ans += 1
print(ans)