cut_pat::String->[[String]]
cut_pat [] = [[]]
cut_pat (x:xs) = [ ((x:(head y)):tail y) | y <- cut_pat xs , y/= []]++[ [x]:y | y <- cut_pat xs]

calc::[[String]]->Int
calc []=0
calc (x:xs) = let nums = map read x  in  (sum nums) + (calc xs)

main::IO()
main=do
  st<-getLine
  print  (calc(cut_pat st))
