n = eval(input())

ans = 0

for j in n:

	ans += int(j)

if ans % 9 == 0:

	print("Yes")

else:

	print("No")
n = int(eval(input()))

if n % 9 == 0:

  print("Yes")

else:

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

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

-n = eval(input()) -ans = 0 -for j in n: -    ans += int(j) -if ans % 9 == 0: +n = int(eval(input())) +if n % 9 == 0: