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

def n_1bargar(num)
  if num == 0
    "P"
  else
    "B" + n_1bargar(num - 1) + "P" + n_1bargar(num - 1) + "B"
  end
end

bargar = n_1bargar(N)

eat = bargar.slice(0, X)

puts eat.count("P")
