function Main(input) {
  input = input.replace(/\n/g, ' ').split(" ");
  var a = input[0];
  var ans = 0;
  var mem = 0;
  for(var i=0;i<a.length;i++){
    ans+=+a.slice(i,i+1);
  }
  console.log((ans%9==0)?"Yes":"No");
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
