append :: Int -> Int -> Int
append a b = 10 * a + b

solve :: [Int] -> Int
solve [] = error "invalid"
solve [x] = x
solve (x:y:xs) = x * (2 ^ length xs) + solve (y:xs) + solve (append x y : xs)

main :: IO ()
main = getLine >>= print . solve . map (read . (:[]))
