import java.util.Scanner;

fun main (args : Array<String>) {
  val input = Scanner(System.`in`)
  
  while (input.hasNext()) {
    val N = input.next()
    var digitSum = 0
    
    for (d in N) {
      digitSum += d - '0'
    }
    
    if (digitSum % 9 == 0) {
      println("Yes")
    } else {
      println("No")
    }
  }
}