import Control.Applicative ((<$>))
import qualified Control.Monad as Monad (when)
import qualified Data.Char as Char (digitToInt)

main = do
    s <- getLine
    Monad.when (read s /= 0) $ do
        print $ sum $ Char.digitToInt <$> s
        main