-- Character - Sum of Numbers

import Control.Applicative
import Data.Char

main :: IO ()
main = do
  xs <- takeWhile (/= "0") . lines <$> getContents
  mapM_ (putStrLn . show . sum . map digitToInt)  xs

