module Main where

import Control.Monad
import Control.Applicative
import Data.List

solve :: Int -> String
solve n = if (n `mod` 9) == 0 then "Yes" else "No"

main :: IO ()
main = do
    n <- readLn
    print $ solve n