#176-B



N = int(eval(input()))

mod = N % 9



if mod == 0:

  print('Yes')

else:

  print('No')

#176-B



N = eval(input())

sum = 0

for i in range(1,len(N)+1):

  sum += int(N[-i])



if int(sum) % 9 == 0:

  print('Yes')

else:

  print('No')

# 176-B
N = int(eval(input()))
mod = N % 9
if mod == 0:
    print("Yes")
else:
    print("No")

# 176-B
N = eval(input())
sum = 0
for i in range(1, len(N) + 1):
    sum += int(N[-i])
if int(sum) % 9 == 0:
    print("Yes")
else:
    print("No")

-N = int(eval(input())) -mod = N % 9 -if mod == 0: +N = eval(input()) +sum = 0 +for i in range(1, len(N) + 1): +    sum += int(N[-i]) +if int(sum) % 9 == 0: