"use strict";

function main(input) {
  input = input.trim().split("");
  let ans = 0;
  if (input[0] === 0) {
    console.log("No");
    return;
  }
  for (const str of input) {
    ans += Number(str);
  }
  if (ans % 9 === 0) {
    console.log("Yes");
  } else {
    console.log("No");
  }
}

function numberSort(array) {
  array.sort(f);
  return array;
}

var f = function (a, b) {
  return a - b;
};

main(require("fs").readFileSync("/dev/stdin", "utf-8"));
