import Foundation

let n = readLine()!.trimmingCharacters(in: .whitespacesAndNewlines).split(separator: Character(""))

var acc = 0

for ch in n {
  acc += Int(ch)!
}

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