object Main {
  def main(args: Array[String]): Unit = {
    val nums    = scala.io.StdIn.readLine
    var sum_mod_9 = 0
    ( 0 until nums.length ).foreach{ i=>
      sum_mod_9 = ( sum_mod_9 + ( nums( i ).toInt - 48 ) )%9
    }
    if( sum_mod_9 == 0 ) println( "Yes" )
    else                 println( "No" )
  }
}