import java.util.*

fun main(args: Array<String>) {
    val scan = Scanner(System.`in`)
    var kotlin=scan.nextLine()

    var ans = 0
    var total = 0
    for(x in kotlin)
    {
        total+=Character.getNumericValue(x);
        total = (total - 9*((total-1)/9))
    }
    if(total==9 || total==0)
        println("Yes")
    else
        println("No")

}
