N=int(eval(input()))

if N%9==0:

  print('Yes')

else:

  print('No')
N = eval(input())

cnt = 0

for i in range(10):

  cnt += i * N.count(str(i))

print(("Yes" if cnt % 9 == 0 else "No"))
N = int(eval(input()))
if N % 9 == 0:
    print("Yes")
else:
    print("No")

N = eval(input())
cnt = 0
for i in range(10):
    cnt += i * N.count(str(i))
print(("Yes" if cnt % 9 == 0 else "No"))

-N = int(eval(input())) -if N % 9 == 0: -    print("Yes") -else: -    print("No") +N = eval(input()) +cnt = 0 +for i in range(10): +    cnt += i * N.count(str(i)) +print(("Yes" if cnt % 9 == 0 else "No"))