fun main(){
    val N = readLine()!!.split("").filter { it != "" }.map { it.toLong() }
    val zeroLong = 0.toLong()
    if(N.sum() % 9 == zeroLong){
        println("Yes")
    }else {
        println("No")
    }
}