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

sumC :: String -> Int
sumC [] = 0
sumC (x:xs) = (ord x - ord '0') + sumC xs

main = do
    s <- getLine
    if s == "0" then return()
    else do 
      putStrLn $ show(sumC s)
      main
    