import           Control.Applicative
import           Control.Monad
import qualified Data.ByteString.Lazy.Char8 as B
import           Data.Char

sumDigits :: B.ByteString -> Int
sumDigits = sum . fmap digitToInt . B.unpack

main :: IO ()
main = do
    xss <- takeWhile (/= B.pack "0") . B.lines <$> B.getContents
    mapM_ (print . sumDigits) xss

