function Main(input) {
  input = input.trim().split("\n");
  const total = input[0].split('').reduce((total, curr) => {
    return parseInt(total,10) + parseInt(curr, 10)
  });
  if (total % 9 === 0) {
    console.log('Yes');
  } else {
    console.log('No');
  }
}

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