fun solver(n: String): String {
    val sum = n.toCharArray().map { (it - 0x30).toInt() }.sum()

    return if (sum % 9 == 0) "Yes" else "No"
}

fun main(args: Array<String>) {
    //val (n, x, t) = readLine()!!.split(" ").map { it.toInt() }
    val n = readLine()!!

    //val n = "31415926535897932384626433832795028841971693993751058209749445923078164062862089986280"

    val result = solver(n)

    println(result)
}
