

fun main(){
    val n = readLine()!!.split(" ")[0].toCharArray().map { it.toInt() }
    var total = 0
    for (i in 0 until n.size){
        total += n[i] - 48
    }
    if (total % 9 == 0){
        println("Yes")
    } else if (total == 0){
        println("Yes")
    } else {
        println("No")
    }

}