size::Int->Int
size 0 = 1
size n = 2*(size (n-1))+3

pate::Int->Int
pate 0 = 1
pate n = 2*(pate (n-1))+1

solver::Int->Int->Int
solver 0 k = if k >= 1 then 1 else 0
solver n k = if ((size (n-1))+1) > k
                then solver (n-1) (k-1)
                else if ((size (n-1))+2) > k
                        then pate (n-1)
                        else (pate (n-1)) + 1 + (solver (n-1) (k- ((size (n-1)) + 2 )))

main::IO()
main=do
  nkc<-getLine
  let n:k:[]=map read (words nkc)
  print (solver n k)