function Main(arg) {
  let N = arg.trim();
  let resut = 0n;
  for(let i = 0; i<N.length;i++){
    resut += BigInt(N[i]);
  }
  if(resut % 9n != 0n){
    console.log('No');
  } else {
    console.log('Yes');
  }

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