import Control.Applicative
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B
import Data.Bool (bool)
import Data.Char (digitToInt)

main :: IO ()
main = solve <$> f >>= putStrLn
  where
    f = head <$> B.words <$> B.getLine

solve :: ByteString -> String
solve bs = bool "No" "Yes" $ r == 0
  where
    r = B.foldl f 0 bs
    f r c = (r + digitToInt c) `mod` 9
