class MultipleOf9
  def initialize(n)
    @n = n
  end

  def solve
    if @n.chars.reduce(0){|r, c| (c.to_i + r) % 9} == 0
      "Yes"
    else
      "No"
    end
  end
end

def run
  puts MultipleOf9.new(gets).solve
end

run
