def f(n,x)
	return 1 if n==0
	return 0 if x<=1
	p = 1<<(n+1)
	if x<p-1 then
		return f(n-1,x-1)
	elsif x==p-1 then
		return p/2 
	elsif x>=2*p-3 then
		return p-1
	else 
		return p-1-f(n-1,2*p-4-x)
	end
end

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

puts f(n,x)
