let input = require('fs').readFileSync('/dev/stdin', 'utf8')
// let input = require('fs').readFileSync('./sample_b.txt', 'utf8')
.split(/\n| /)
// .map(item => parseInt(item))
.slice(0,-1)

const number = input[0].split("").map(item => parseInt(item))
const isNine = number.reduce((prev, item) => prev + item ,0) % 9 === 0

console.log(isNine ? 'Yes' : 'No')