object Main {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn.readLine
    val datN = readLine.split("").filterNot(_ == "").map(_.toInt)

    val ans = datN.sum % 9 == 0
    println(if(ans) "Yes" else "No")
  }
}
