fun main(args:Array<String>) {
    var n = readLine()!!

    var tmp = 0L

    for (element in n) {
        tmp += element.toString().toLong()
    }


    if (tmp % 9L == 0L) {
        print("Yes")
    } else {
        print("No")
    }
}