import Data.Char import Data.List import Numeric fromStringToBit :: String -> Int fromStringToBit s = fst $ head $ readInt 2 (`elem` "01") digitToInt t where t = map (\x -> if x == 'L' then '0' else '1') s tree :: Int -> [[Int]] tree = unfoldr f where f 0 = Nothing f 1 = Just ([1], 0) f x = Just ([2 ^ (x - 1) .. (2 ^ x - 1)], x - 1) main :: IO () main = do s <- getLine let t = fromStringToBit s u = tree $ (length s) + 1 print $ (head u) !! t