main = do
    putStrLn.solve=<<getLine

solve :: String -> String
solve s = if mod (sum (arr s)) 9 == 0 then "Yes" else "No"
arr :: [Char] -> [Int]
arr s = map read $ map charToString s
charToString :: Char -> String
charToString c = [c]