n = int(eval(input()))



print(("Yes" if n % 9 == 0 else "No"))

n = eval(input())



temp = 0



for i in range(len(n)):

    temp += int(n[i])





print(("Yes" if temp % 9 == 0 else "No"))

n = int(eval(input()))
print(("Yes" if n % 9 == 0 else "No"))

n = eval(input())
temp = 0
for i in range(len(n)):
    temp += int(n[i])
print(("Yes" if temp % 9 == 0 else "No"))

-n = int(eval(input())) -print(("Yes" if n % 9 == 0 else "No")) +n = eval(input()) +temp = 0 +for i in range(len(n)): +    temp += int(n[i]) +print(("Yes" if temp % 9 == 0 else "No"))