import Foundation

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

var acc = 0

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

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