(async () => {
    let input = '';
    for await (const chunk of process.stdin) input += chunk;

    if(input.split('').map(v => +v).reduce((sum, d) => sum + d, 0) % 9 == 0){
        console.log('Yes');
    }else{
        console.log('No');
    }
})();
