def f(n, x, a, b)
  if n == 0
    return 0 if x <= 0
    return 1
  elsif x <= 1 + a[n-1]
    return f(n-1, x-1, a, b)
  else
    return b[n-1] + 1 + f(n-1, x-2-a[n-1], a, b)
  end
end

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

a = [1]
b = [1]

n.times do |i|
  a.push(a[i] * 2 + 3)
  b.push(b[i] * 2 + 1)
end

puts f(n, x, a, b)