function main(input){
  input = input.split('\n');

  const ns = input[0].split('').map(Number);
  const sum = ns.reduce((sum, n)=> sum + n, 0)

  console.log((sum%9 == 0)? 'Yes': 'No');

}

main(require('fs').readFileSync('/dev/stdin', 'utf8').trim());
