a = gets.chomp.split("").map(&:to_i)

nmod = 0
#test = 0

a.each do |e|
  nmod = (nmod+e) % 9
  #test += e
  #p test
  #p nmod
end

#puts("#{test % 9}")
#puts("#{nmod}")

if nmod == 0
  puts("Yes")
else
  puts("No")
end