import qualified Data.ByteString.Lazy.Char8 as LC branch :: Integral a => a -> Char -> a branch n c = case c of 'L' -> 2 * n 'R' -> 2 * n + 1 _ -> n currentRoad :: Integral a => LC.ByteString -> a currentRoad = LC.foldl' branch 1 main :: IO () main = print . currentRoad =<< LC.getContents