function main(arg) {
    
    let n = arg
    
    let sum=0
    for(let i=0; i < n.length; i++) {
        sum+=Number(n[i])
    }
    
    console.log(sum%9==0 ? "Yes" : "No")


}


main(require("fs").readFileSync("/dev/stdin", "utf8"));
