function Main(input) {
    input = input.trim();
    let sum = 0;
    for (let i=0; i < input.length; i++){
        sum += parseInt(input[i]);
    }
 
    if (sum % 9 == 0) {
        console.log('Yes');
    } else {
        console.log('No');
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));