module Main where

import Control.Applicative
import Numeric
import Data.Char

main :: IO ()
main = loop

loop :: IO()
loop = do
  { [n] <- getIntegers
  ; if n == 0 then return ()
    else do
      {  print (sum (map digitToInt (show n)))
       ; loop
       ;
       }
  }

-- main = do
--  { [x] <- getInts
--  ; loop x
--  ; 
--    }

-- loop :: Int -> IO [Int]
-- loop 0 = return []
-- loop x = do
--   { x <- getInts
  
    
--
getIntegers :: IO [Integer]
getIntegers = map read . words <$> getLine

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

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords . map show

getDoubles :: IO [Double]
getDoubles = map read . words <$> getLine

putDoubles :: [Double] -> IO ()
putDoubles = putStrLn . unwords . map showDouble

showDouble :: Double -> String
showDouble d = showFFloat Nothing d ""


