import Data.Char

calcSum :: String -> Int
calcSum numStr = foldl (\acc x -> acc + digitToInt x) 0 numStr

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