N=int(eval(input()))

n= str(N)

total=0

for i in range(len(n)):

  k = n[i]

  k = int(k)

  total += k

  

if total%9==0:

  print("Yes")

else:

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

point=0

for i in range(len(n)):

  point+=int(n[i])

  

if point%9==0:

  print("Yes")

else:

  print("No")
N = int(eval(input()))
n = str(N)
total = 0
for i in range(len(n)):
    k = n[i]
    k = int(k)
    total += k
if total % 9 == 0:
    print("Yes")
else:
    print("No")

n = eval(input())
point = 0
for i in range(len(n)):
    point += int(n[i])
if point % 9 == 0:
    print("Yes")
else:
    print("No")

-N = int(eval(input())) -n = str(N) -total = 0 +n = eval(input()) +point = 0 -    k = n[i] -    k = int(k) -    total += k -if total % 9 == 0: +    point += int(n[i]) +if point % 9 == 0: