S = []
P = []
B = []
def re(n,i)
  if i == 1
    0
  elsif i <= 1 + S[n-1]
    re(n-1,i-1)
  elsif i == 2 + S[n-1]
    re(n-1,i-2) + 1
  elsif i < S[n] - 1
    P[n-1] + 1 + re(n-1,i-2-S[n-1])
  elsif i == S[n] - 1
    P[n]
  elsif i == S[n]
    P[n]
  end
end
n,x = gets.chomp.split(" ").map(&:to_i)
P[0] = 1
S[0] = 1
B[0] = 0
n.times do |i|
  S[i+1] = S[i] * 2 + 3
  P[i+1] = P[i] * 2 + 1
  B[i+1] = S[i+1] - P[i+1]
end
puts re(n,x)