function Main(input) {
    const N = input.trim().split('\n')[0];

    let result = 0;
    for (let n of N) {
        result += n;
        result %= 9;
    }
    if (result) {
        console.log('No');
    } else {
        console.log('Yes');
    }

    return;
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));