function Main(input) {
  input = input.split('');
  
  var total = 0;
  
  for(var i = 0; i < input.length-1 ; i++){
  	total = total + parseInt(input[i], 10);
  }
  
  console.log("%s", total % 9 ? "No" : "Yes");
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));