import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val N = sc.nextLine

  val z = if (N == "0" || N.foldLeft(0L)((z, x) => z + x.toLong) % 9L == 0L) "Yes" else "No"

  println(z)
}
