const input = require("fs").readFileSync("/dev/stdin", "utf8")

const lines = input.split('\n')
let N = lines[0].trim()

let sum = 0
for (let i = 0; i < N.length; i++) {
    sum += N[i] - 0
}

console.log(sum % 9 === 0 ? 'Yes' : 'No')
