fun main(args: Array<String>) {
    val n = readString()

    var t = 0L
    n.forEach {
        t += it - '0'
    }
    if (t % 9 == 0L) {
        println("Yes")
    } else {
        println("No")
    }
}

// read
fun readString() = readLine()!!