import Control.Applicative
import Control.Monad
import Data.Array
import Data.Array.ST
import Data.Char
import Data.List
import qualified Data.Map as M
import qualified Data.Set as S
import Text.Printf

readInts :: IO [Int]
readInts = map read . words <$> getLine

main :: IO ()
main = do
  x <- readLn
  when (x /= 0) $ do
    print $ sumDigits x
    main

sumDigits :: Integer -> Integer
sumDigits x
  | q == 0    = r
  | otherwise = r + sumDigits q
 where (q, r) = x `quotRem` 10

