function Main(input) {
  
    input = input.split("")
    let All_plus = input.reduce(function(a, b) {
        return Number(a) + Number(b);
    })
    
  	if(All_plus%9 === 0){
	console.log("Yes");
    }else{
    console.log("No");
    }
}

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