process.stdin.resume();
process.stdin.setEncoding('utf8');
var lines = [];
var w;
var count= 0;
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
  var x = lines[0];
  for(var i = 0; i<x.length;i++){
     w =  x.slice(i,i+1);
     count = count + parseInt(w[0]);
  }
  if(count % 9 == 0){
    console.log('Yes');
  }else if (count % 9 != 0){
    console.log('No');
  }
});