n,x=gets.split.map(&:to_i)
$a=Array.new(50,0).map.with_index{|n,i| 2**(i+2)-3}
$p=Array.new(50,0).map.with_index{|n,i| 2**(i+1)-1}

def f(n,x)
    if n==0
        x<=0 ? 0:1
    elsif x<=1+$a[n-1]
        f(n-1,x-1)
    else
        $p[n-1]+1+f(n-1,x-2-$a[n-1])
    end
end
p f(n,x)

