main = do
    line <- getLine
    let [n, x] = map read $ words line
    putStrLn . show $ solve n x

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

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

solve n x
    | x == 1            = 0
    | x <= pile + 1     = solve (n - 1) (x - 1)
    | x == pile + 2     = pate + 1
    | x <= pile * 2 + 2 = pate + 1 + solve (n - 1) (x - 2 - pile)
    | otherwise         = pate * 2 + 1
      where
        pile = piles (n - 1)
        pate = pates (n - 1)
