n = eval(input())



m = 0

for i in n:

    m += int(i)



if m % 9:

    print('No')

else:

    print('Yes')

n = eval(input())

total = 0

for i in range(10):

    total += n.count(f'{i}') * i

print(('Yes' if total%9==0 else 'No'))

n = eval(input())
m = 0
for i in n:
    m += int(i)
if m % 9:
    print("No")
else:
    print("Yes")

n = eval(input())
total = 0
for i in range(10):
    total += n.count(f"{i}") * i
print(("Yes" if total % 9 == 0 else "No"))

-m = 0 -for i in n: -    m += int(i) -if m % 9: -    print("No") -else: -    print("Yes") +total = 0 +for i in range(10): +    total += n.count(f"{i}") * i +print(("Yes" if total % 9 == 0 else "No"))