def burger(l)
  if l == 0
    'P'
  else
    'B' + burger(l -1) + 'P' + burger(l -1) + 'B'
  end
end

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

burger = burger(N)
puts burger.slice(0..(X - 1)).count('P')

