program abc115_d
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: n,x,i
    integer(int64), allocatable:: a(:),p(:)
    read*, n,x
    allocate(a(0:n), p(0:n))
    a(0)=1
    p(0)=1
    do i=1,n
        a(i) = 2*a(i-1)+3
        p(i) = 2*p(i-1)+1
    end do

    print'(i0)', solve(n,x)

contains
    recursive function solve(n,x) result(ret)
        integer(int64):: n,x,ret
        if (n==0) then
            if (x <= 0) then
                ret = 0
            else
                ret = 1
            end if
        else if (x <= 1+a(n-1)) then
            ret = solve(n-1,x-1)
        else
            ret = p(n-1) + 1 + solve(n-1, x-2-a(n-1))
        end if
    end function
end program abc115_d