N = int(eval(input()))



N_sum = sum(list(map(int, str(N))))



if N % 9 == 0 and N_sum % 9 == 0:

    print('Yes')

else:

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

 

if N % 9 == 0:

    print('Yes')

else:

    print('No')
N = int(eval(input()))
N_sum = sum(list(map(int, str(N))))
if N % 9 == 0 and N_sum % 9 == 0:
    print("Yes")
else:
    print("No")

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

-N_sum = sum(list(map(int, str(N)))) -if N % 9 == 0 and N_sum % 9 == 0: +if N % 9 == 0: