function Main(input) {
  const N = input.trim()
  const Narray = N.split('').map(Number)

  const tmp = Narray.reduce((acc,value) => acc + value);
  tmp % 9 === 0 ? console.log("Yes") : console.log('No')
  }

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