import Data.Char

main = getContents >>= putOut.formatOut.solve.formatIn
  where putOut s | null s || last s == '\n' = putStr s
                 | otherwise                = putStrLn s
  
formatIn :: String -> [[Int]] 
formatIn = map (map digitToInt).takeWhile (/="0").lines

formatOut :: [Int] -> String
formatOut = unlines.map show

solve :: [[Int]] -> [Int]
solve = map sum