module Main where

import Data.Char

main :: IO ()
main =  do
 { [n] <- getInts
 ; if n == 0 then done
   else print (sum (map digitToInt (show n))) >> main
 }

done :: IO ()
done = return ()

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