N =  int( eval(input()) )

if N % 9 == 0 :

    print('Yes')

if N % 9 != 0 :

    print('No')

n = eval(input( ))

result = sum(list(map(int, str(n))))



if result % 9 == 0 :

    print('Yes')

else :

    print('No')

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

n = eval(input())
result = sum(list(map(int, str(n))))
if result % 9 == 0:
    print("Yes")
else:
    print("No")

-N = int(eval(input())) -if N % 9 == 0: +n = eval(input()) +result = sum(list(map(int, str(n)))) +if result % 9 == 0: -if N % 9 != 0: +else: