fun main () {
    val list = readLine()!!.toCharArray().map {it.toString()}.toMutableList()
    var sum = 0
    for (num in list) {
        sum += num.toInt()
    }
    if (sum % 9 == 0 ) println("Yes") else println("No")
}