def numofbits1(bits)
  num = 0
  mask = 1
  while(mask != 0) do
    break if 1 << 31  == mask
    num += 1 if (bits & mask) != 0
    mask <<= 1
  end
  num
end

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

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

inputs = STDIN.read.split("\n")
bit = (2 ** n) - 1
inputs.each do |input|
  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 numofbits1(bit)