import Control.Monad
import Control.Applicative
import Data.List
import qualified Data.Vector as V
import Debug.Trace as De

main = do
  n <- readLn :: IO Integer
  let ans = if (mod n 9) == 0 then "Yes" else "No"
  putStrLn $ ans