import Foundation

//let n = readLine()!.trimmingCharacters(in: .whitespacesAndNewlines)
let n = readLine()!

var acc = 0

for ch in n {
  acc = (acc &+ Int(String(ch))!) % 9
}

print(acc % 9 == 0 ? "Yes" : "No")
