N = int(eval(input()))

if(N%9 == 0):

	print("Yes")

else:

	print("No")
N = list(map(int,eval(input())))

if(sum(N) % 9 == 0):

	print("Yes")

else:

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

N = list(map(int, eval(input())))
if sum(N) % 9 == 0:
    print("Yes")
else:
    print("No")

-N = int(eval(input())) -if N % 9 == 0: +N = list(map(int, eval(input()))) +if sum(N) % 9 == 0: