function MainB(input){
    const num = input.split('').map(Number);
    if(num.length === 1 && num===0){
        console.log('Yes');
    }
    const sum = num.reduce((a,b)=> a+b);
    console.log(sum%9==0 ? 'Yes' : 'No');
}
MainB(require("fs").readFileSync("/dev/stdin", "utf8").trim());
