N = int(eval(input()))



if N % 9 == 0:

    print('Yes')

else:

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



SUM = 0

for i in N:

    SUM += int(i)



if SUM % 9 == 0:

    print('Yes')

else:

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

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

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