defmodule Main do
  def main do
    n = IO.gets("")
        |> String.trim()
        |> String.codepoints()
        |> Enum.map(&String.to_integer/1)

    sum_of_digits = List.foldl(n, 0, &Kernel.+/2)

    case rem(sum_of_digits, 9) do
      0 -> IO.puts("Yes")
      _ -> IO.puts("No")
    end
  end
end
