n,x = gets.chomp.split(" ").map(&:to_i)

result = 0

while true do
  length = 2 ** (n + 2) - 3
  p_num = 2 ** (n + 1) - 1
  if n == 0
    result += 1
    break
  elsif x == 1 # 最下層
    break
  elsif x == length # 最上層
    result += p_num
    break
  elsif x == length / 2 + 1 # ちょうど真ん中
    result += (p_num / 2 + 1)
    break
  elsif x <= length / 2
    n -= 1
    x -= 1
  else
    result += (p_num / 2 + 1)
    n -= 1
    x -= length / 2 + 1
  end
end

puts result

