import qualified Data.ByteString.Char8 as B
import           Data.Char

main :: IO ()
main = do
  n <- B.getLine
  putStrLn $ if solve n then "Yes" else "No"

solve :: B.ByteString -> Bool
solve = (== 0) . B.foldl' f 0
 where
   f r c = (r + digitToInt c) `rem` 9