import Control.Applicative
import Control.Monad
import Data.Char

main :: IO ()
main = fix $ \loop -> do
    s <- sum . map digitToInt <$> getLine
    unless (0 == s) $ do
        putStrLn . show $ s
        loop
