input = STDIN.gets
splited = input.split(" ")

n = splited[0].to_i
m = splited[1].to_i

bit = (2 ** n) - 1
m.times do
  input = STDIN.gets
  splited = input.split(" ")
  l = splited[0].to_i
  r = splited[1].to_i

  nextbit = ((2 ** (r-l+1)) - 1) << (l-1)
  bit = bit & nextbit
end

puts bit.to_s(2).count("1")