function Main(input){
  let sum = 0;
  let Input = input.toString();
  for(let i= 0; i < Input.length; i++){
    let num = parseInt(Input[i]);
    sum += num;
  }
  if(sum % 9 === 0){
    console.log("Yes");
    }
  else{
    console.log("No");
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));