N = int(eval(input()))

if N%9==0:

  print('Yes')

else:

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

a=0

for i in range(len(N)):

  a+=int(N[i])%9

if a%9==0:

  print('Yes')

if a%9!=0:

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

N = eval(input())
a = 0
for i in range(len(N)):
    a += int(N[i]) % 9
if a % 9 == 0:
    print("Yes")
if a % 9 != 0:
    print("No")

-N = int(eval(input())) -if N % 9 == 0: +N = eval(input()) +a = 0 +for i in range(len(N)): +    a += int(N[i]) % 9 +if a % 9 == 0: -else: +if a % 9 != 0: