import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Char

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    n <- getLine
    let t = foldl' f 0 n
    let m = t `mod` 9
    putStrLn $ if m == 0 then "Yes" else "No"

f s c = s + (digitToInt c)