import System.Exit
import Data.Char

main = do
    cs <- getLine
    if cs == "0" then exitSuccess
                 else solve cs
    main

solve :: [Char] -> IO ()
solve = print . sum . map digitToInt
