defmodule Main do
 def multiple_of_9(num) do
   sum_of_digits = Integer.digits(num)
          |> Enum.sum
   cond do
     rem(sum_of_digits,9) == 0 -> "Yes"
     true -> "No"
   end
 end
 
 def main do
    num = IO.read(:line) |> String.trim() |> String.to_integer
    IO.puts multiple_of_9(num)
 end
end