module Main where
--import Debug.Trace
import Data.List
import Data.Char
import Data.Array
import Data.Maybe
import Data.Ord
import Control.Monad

solve :: [String] -> [Int]
solve [] = []
solve (x:xs) = iter x: solve xs where
    iter [] = 0
    iter (d:ds) = ord d - ord '0' + iter ds
                
readUntil :: (String -> Bool) -> IO [String]
readUntil eof = iter where
    iter = getLine >>=
            (\a -> if eof a then return [] else fmap (a:) iter)
            
eof :: String -> Bool
eof s = s == "0"

main :: IO() 
main = do
    l   <- readUntil eof
    mapM_ putStrLn $ map show (solve l)

