N = str(eval(input()))



a = list(N)



result = 0



for x in a:

    x = int(x)

    result += x



if result%9 == 0:

    print("Yes")

else:

    print("No")
N = str(eval(input()))



a = sum([int(n) for n in list(N)])



if a%9 == 0:

    print("Yes")

else:

    print("No")

N = str(eval(input()))
a = list(N)
result = 0
for x in a:
    x = int(x)
    result += x
if result % 9 == 0:
    print("Yes")
else:
    print("No")

N = str(eval(input()))
a = sum([int(n) for n in list(N)])
if a % 9 == 0:
    print("Yes")
else:
    print("No")

-a = list(N) -result = 0 -for x in a: -    x = int(x) -    result += x -if result % 9 == 0: +a = sum([int(n) for n in list(N)]) +if a % 9 == 0: