(async () => {
  const buffers = [];
  for await (const chunk of process.stdin) buffers.push(chunk);
  const buffer = Buffer.concat(buffers);
  const text = buffer.toString();
  const lines = text.split(/\r?\n/);
  sum = lines.forEach((line, index) => {
    const sum = [].reduce.call(line, (accumulator, currentValue) => {
      return Number(accumulator) + Number(currentValue);
    });
    if (sum % 9 === 0) {
      console.log("Yes");
    } else {
	  console.log("No");
    }
  });
})();