import Control.Monad
import Control.Applicative

solve :: String -> String
solve s =
    show $ sum [read [c] | c<-s]

main =
    mapM_ putStrLn =<< map solve . takeWhile (/= "0") . lines <$> getContents 
