main :: IO ()
main = do
  (n:x:xs) <- (map read) . words <$> getLine
  putStrLn . show $ solve n x

solve :: Integer -> Integer -> Integer
solve n x = calcPutties (layers n) x

calcPutties :: [(Integer, Integer)] -> Integer -> Integer
calcLayers _ 0 = 0
calcPutties ((nLay, nPut):ns) x
  | nLay == x = nPut
  | nLay > x && x > (nLay `div` 2) = (snd . head $ ns) + 1 + calcPutties ns (x - (nLay `div` 2) - 1)
  | (nLay `div` 2) >= x && x > 1 = calcPutties ns (x - 1)
  | otherwise = 0

-- (layer, putty)
layers :: Integer -> [(Integer, Integer)]
layers 0 = [(1,1)]
layers n =
  let all@((prevLayer, prevPutty) : xxs) = layers (n-1)
  in (prevLayer * 2 + 3, prevPutty * 2 + 1) : all
