function Main(input) {
  const lines = input.split('\n');
  const number = lines[0].split('').map(i => parseInt(i));
  const sum = number.reduce((a, b) => a + b);
  const flag = sum % 9 === 0;
  console.log(flag? 'Yes': 'No');
}

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