import Data.Char(digitToInt)

main = interact $ show' . solve . read' . lines
  where
    solve = map solveRow
    solveRow = sum . map digitToInt
    show' = unlines . map show
    read' = takeWhile (/= "0")

