#takasa=2^(n+2)-3
#pathi=2^(n+1)-1
$P=[]
i=1
53.times{
	$P<<i
	i*=2
}

def maisu(n,x)
	if x==1
		return 0
	elsif x<=$P[n+1]-3
		return maisu(n-1,x-1)
	elsif x==$P[n+1]-2
		return $P[n]-1
	elsif x==$P[n+1]-1
		return $P[n]
	elsif x<=$P[n+2]-5
		return $P[n]+maisu(n-1,x-$P[n+1]+1)
	else
		return $P[n+1]-1
	end
end

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