
object Main extends App {
  
  val sc = new java.util.Scanner(System.in)
  val N: Seq[Char] = sc.next()
  val sum = N.map(_.asDigit).sum
  if (sum % 9 == 0) {
    println("Yes")
  } else {
    println("No")
  }

}
