import Data.List
main = do
  s <- getLine
  putStrLn $ if ((`mod`9) . sum . conv) s ==0 then "Yes" else "No"

conv [] = []
conv (x:xs) = (read' x) : conv xs

read' x
  |x=='0' = 0
  |x=='1' = 1
  |x=='2' = 2
  |x=='3' = 3
  |x=='4' = 4
  |x=='5' = 5
  |x=='6' = 6
  |x=='7' = 7
  |x=='8' = 8
  |x=='9' = 9