fun main(args: Array<String>) {
    readLine()?.let {
        var result = 0
        it.forEach {
           result += it.toString().toInt()
        }
        val r = if (result % 9 == 0 || result == 0) {
            "Yes"
        } else {
            "No"
        }
        println(r)
    }
}