fun main() {
    val N = readLine()!!.split("").toMutableList()
    N.removeAt(N.size-1)
    N.removeAt(0)
    val total = N.map { it.toLong() }.sum()
    if (total % 9L == 0L) {
        println("Yes")
    } else {
        println("No")
    }
}