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

A = [1]
P = [1]

(0..N).each do |i|
  A[i + 1] = A[i] * 2 + 3
  P[i + 1] = P[i] * 2 + 1
end

def dfs(n, x)
  if n == 0
    x <= 0 ? 0 : 1
  elsif x <= 1 + A[n - 1]
    dfs(n - 1, x - 1)
  else
    P[n - 1] + 1 + dfs(n - 1, x - 2 - A[n - 1])
  end
end

puts dfs(N, X)