import Control.Monad
import Control.Applicative
import Data.Functor
import Data.List
import Data.Char

digitSum = foldr1 (+) . map digitToInt

main = getContents >>= mapM_ print . map digitSum . takeWhile (/="0") . lines