N = eval(input())



sum = 0

if int(N) != 0:

    data_size = len(N)

    for data_size in range(data_size):

        sum += int(N[data_size])



else:

    sum = 0



if sum%9 == 0:

    print('Yes')

else:

    print('No')
if int(eval(input()))%9 == 0:

  print('Yes')

else:

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

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

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