import java.util.*
fun main(args: Array<String>) {
    val reader = Scanner(System.`in`)
    val numStr = reader.next()

    var sum = 0L
    numStr.forEach {
        sum += it - '0'
    }

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