-- local n = io.read("n")
-- local k = io.read("n")
local n, k = 50, 4321098765432109
local g = {[0] = {1, 1}}
for i = 1, n do
	local c0 = g[i - 1][1]
	local p0 = g[i - 1][2]
	local c = c0 * 2 + 3
	local p = p0 * 2 + 1
	g[i] = {c, p}
end
local function f(_n, _k)
	if _k <= 0 then
		return 0
	end
	if _n <= 0 then
		return 1
	end
	local c = g[_n][1]
	local hc = (g[_n][1] + 1) // 2
	if _k >= c then
		return g[_n][2]
	elseif _k == hc then
		return f(_n - 1, _k - 2) + 1
	elseif _k < hc then
		return f(_n - 1, _k - 1)
	else
		return g[_n - 1][2] + 1 + f(_n - 1, _k - hc)
	end
end
print(f(n, k))