import Control.Monad

y f = f (y f)
main = do
  str <- getLine
  when (str /= "0") $ do
    print $ flip y str $
      \f ss -> case ss of
        []      -> 0
        (s:sl)  -> (read [s] :: Int) + f sl
    main