console.log((args=>{
  const N = args.trim().split``.map(v=>v|0);
  const L = N.length;
  let s = 0;
  for ( let i = 0; i < L; i++ ) s += N[i];
  return (s%9)?'No':'Yes';
})(require('fs').readFileSync('/dev/stdin','utf8')));
