N = int(eval(input()))

if N%9:

    print('No')

else:

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

k = 0

for i in N:

    k += int(i)

if k%9:

    print('No')

else:

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

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

-N = int(eval(input())) -if N % 9: +N = eval(input()) +k = 0 +for i in N: +    k += int(i) +if k % 9: