var readline = require('readline');
var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
    terminal: false
});

rl.on('line', function (line) {
    let sum = 0;
    for(let i=0; i < line.length; i++) {
        sum += Number(line[i]);
    }
    if(sum % 9 === 0) {
        console.log("Yes");
    } else {
        console.log("No");
    }
})