import Data.List( subsequences)
main = do
    s <- getLine
    let powSet = subsequences [1..lngth]
	lngth = length s
	splits (list,[]) _ = map (read::String->Integer) list
	splits (list,_) [] = map (read::String->Integer) list
	splits (list,rem) (pos:ps) =
	  let
	    (l,r) = splitAt pos rem
	  in
	    splits (l:list, r) $ map ((negate pos)+) ps
    print . sum . map sum $ take (2^(lngth-1)) $ reverse $ map (splits ([],s)) powSet