function Main(input) {
    input = input.trim().split("\n").map(function(x) { return x.split(" ")});
    let N = input[0][0];

    let tmp = 0;

    for (let i = 0; i < N.length; i++){
        tmp += parseInt(N[i], 10);
        tmp %= 9;
    }
    if (tmp === 0) console.log("Yes");
    else console.log("No");

}

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