countPatty :: Int -> Int -> Int
countPatty n x = p
    where (t, p) = burger (prep n) (x, 0)

burger :: [(Int,Int)] -> (Int, Int) -> (Int, Int)
burger _ (0, ac) = (0, ac)
burger ((t, p):st) (x, ac)
    | x >= t      = (x-t, ac + p) 
    | otherwise = (bun.burger st.patty.burger st.bun) (x, ac)

bun :: (Int, Int) -> (Int, Int)
bun (0, ac) = (0, ac)       
bun (x, ac) = (x-1, ac)

patty :: (Int, Int) -> (Int, Int)
patty (0, ac) = (0, ac)
patty (x, ac) = (x-1, ac+1)

prep :: Int -> [(Int, Int)] 
prep 0 = [(1, 1)]
prep m = (2*t+3, 2*p+1):xs
    where
        (t, p) = head xs
        xs = prep (m-1)
    
main :: IO() 
main = do
    line1 <- getLine
    let [stN, stX] = words line1
        n = read stN :: Int
        x = read stX :: Int
    let ans = countPatty n x 
    print ans
    