n=int(eval(input()))

l=list(str(n))



wrk=0

for i in l:

    wrk+=int(i)



if wrk % 9 == 0:

    print('Yes')

else:

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



wrk=0

for i in n:

    wrk+=int(i)



if wrk % 9 == 0:

    print('Yes')

else:

    print('No')
n = int(eval(input()))
l = list(str(n))
wrk = 0
for i in l:
    wrk += int(i)
if wrk % 9 == 0:
    print("Yes")
else:
    print("No")

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

-n = int(eval(input())) -l = list(str(n)) +n = eval(input()) -for i in l: +for i in n: