import Data.Char

digitSum = sum . map digitToInt . show

processInputLine (0) = return ()
processInputLine n = print $ digitSum n

main =
    getContents >>= mapM_ processInputLine . map read . lines