function Main(input) {
	input = String(input).split('').map(e=>Number(e)).reduce((a,b)=>a+b)
  	input%9===0?console.log('Yes'):console.log('No')
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));