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