import Control.Monad
import Data.List

burger 0 = 1
burger n = burger (n - 1) * 2 + 3

bun 0 = 1
bun n = bun (n - 1) * 2 + 1

patty n 0 = 0
patty 0 x = 1
patty n x =
    if x > t `div` 2
    then patty (n - 1) (x - t `div` 2 - 1) + bun (n - 1) + 1
    else patty (n - 1) (x - 1)
    where t = burger n

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