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

n, x = gets.chomp.split.map(&:to_i)
s = burger(n)
puts s.slice(0..x - 1).scan("P").length
