import Control.Applicative

import Data.Char
    (digitToInt)

type Problem = [String]

type Result = [Int]

solve :: Problem -> Result

solve xs
    = map (\x -> sum $ map digitToInt x) xs

output :: [Int] -> String

output xs
    = init.concat $ map (\x -> show x ++ "\n") xs

input :: IO [String]

input
    = inputData []

inputData :: [String] -> IO [String]

inputData xs
    = do
        text <- getLine
        if text == "0"
            then return xs
            else inputData $ xs ++ [text]

main :: IO ()

main
    = putStrLn.output =<< solve <$> input