import Control.Monad
import Data.Char (digitToInt)

solver :: String -> Int
solver xs = sum $ map digitToInt xs

main :: IO()
main = do
  n <- getLine
  unless (n == "0") $ do
    print $ solver n
    main