N=list(map(int,list(eval(input()))))

Total=0

for n in N:

  Total+=n

#print(Total//9 , Total/9)

if (Total//9 == Total/9):

  print("Yes")

else:

  print("No")
#ver2

N=list(map(int,list(eval(input()))))

Total=sum(N)

#print(Total//9 , Total/9)

if (Total//9 == Total/9):

  print("Yes")

else:

  print("No")
N = list(map(int, list(eval(input()))))
Total = 0
for n in N:
    Total += n
# print(Total//9 , Total/9)
if Total // 9 == Total / 9:
    print("Yes")
else:
    print("No")

# ver2
N = list(map(int, list(eval(input()))))
Total = sum(N)
# print(Total//9 , Total/9)
if Total // 9 == Total / 9:
    print("Yes")
else:
    print("No")

+# ver2 -Total = 0 -for n in N: -    Total += n +Total = sum(N)