solve :: [Char] -> Int -> String
solve a b
 | null a    = if (b `mod` 9) == 0 then "Yes" else "No"
 | otherwise = solve (tail a) (b + aInt)
   where aInt = (fromEnum (head a)) - 48

main = do
 a <- getLine :: IO [Char]
 putStr $ solve a 0