N, M = gets.chomp.split(" ").map(&:to_i)

li = []
ri = []

for i in 0...M do
  l, r = gets.chomp.split(" ").map(&:to_i)
  li[i] = l
  ri[i] = r
end

answer = 0

for i in 0..N do
  check = true

  for j in 0...M
    if li[j] <= i && i <= ri[j] then
      next
    else
      check = false
      break
    end
  end
  if check then
    answer += 1
  end
end

puts answer
