'use strict'
 
function main(s) {
  s = s.replace(/\r?\n/g,'');
  s = s.split('');
  let kekka = 0;
  for(var i = 0; i < s.length;i++){
    kekka += Number(s[i]); 
  }

  if(kekka % 9 == 0){
    console.log("Yes");
  }else{
    console.log("No");
  }
}
 
main(require("fs").readFileSync("/dev/stdin", "utf8"));
