process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
  var N = lines[0];
  var sum = 0;
  for (var i = 0; i < N.length; i++) {
    sum += parseInt(N.split('')[i]);
  }
  
  var result = 'No';
  if (sum % 9 === 0) result = 'Yes';
  console.log(result);
});