import sys

input = sys.stdin.readline



n = list(eval(input()))

m = len(n)

t = 0

for i in range(m-1):

    t = (t+int(n[i]))%9



if t == 0:

    print("Yes")

else:

    print("No")

if int(eval(input()))%9 == 0:

    print("Yes")

else:

    print("No")

import sys

input = sys.stdin.readline
n = list(eval(input()))
m = len(n)
t = 0
for i in range(m - 1):
    t = (t + int(n[i])) % 9
if t == 0:
    print("Yes")
else:
    print("No")

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

-import sys - -input = sys.stdin.readline -n = list(eval(input())) -m = len(n) -t = 0 -for i in range(m - 1): -    t = (t + int(n[i])) % 9 -if t == 0: +if int(eval(input())) % 9 == 0: