
import Data.Array (Array, listArray, (!))

import Debug.Trace (trace)

b = listArray (0,50) $ iterate (\x->2*x+3) 1
p = listArray (0,50) $ iterate (\x->2*x+1) 1

f 0 0 = 0
f 0 n = 1
f n 1 = 0
f n x
  | x<=1+(b!(n-1))   = f (n-1) (x-1)
  | otherwise = (p!(n-1)) + f (n-1) (x-2-(b!(n-1))) + 1

main = do
  [n,x] <- map read . words <$> getLine
  print $ f n x
