import Control.Applicative
main = do
  v <- (takeWhile (/="0") . lines) <$> getContents
  mapM_ putStrLn $ map (show . aux) $ v 
  where aux :: String -> Int
        aux s = (sum . map (\x->(read::String->Int) [x])) $ s