import Control.Monad -- for replicateM_
import Data.List -- for sort


{-
deal :: IO()
deal = do 
    [n, x] <- map read . words <$> getLine
    info <- replicateM (n-1) getWeight
    -- graph <- buildTree info [[[]]]
    putStrLn $ show info

main :: IO()
main = getLine >>= flip replicateM_ deal . read 
-}

convert :: String -> [Int]
convert xs = map (\x -> read [x] :: Int) xs 

solve :: [Int] -> Int
solve (x:xs) 
    | null xs = mod x 9
    | otherwise = mod (mod x 9 + solve xs) 9

multiple9 :: Int -> String
multiple9 x  
    | mod x 9 == 0 = "Yes"
    | otherwise = "No"

main :: IO()
main = do 
    s <- getLine
    putStrLn $ multiple9 $  sum $ convert s
