function main(input = "") {
    const N = input;
    let cnt = 0;
    N.split("").forEach((v) => {
        cnt += 0 | v;
    })
    return cnt % 9 === 0 ? "Yes" : "No";
}

//******************************
exports.main = main;

function Main(input) {
    console.log(main(input.trim()));
}

if (process.argv[2] !== "test") {
    Main(require("fs").readFileSync("/dev/stdin", "utf8"));
}
