const main = arg => {
  const ary = arg.split('');
  ary.pop();
  const sum = ary.reduce((a, b) => Number(a) + Number(b));
  console.log(sum % 9 === 0 ? 'Yes' : 'No');
};
main(require('fs').readFileSync('/dev/stdin', 'utf8'));