import sys

cin = sys.stdin.readline

n = list(cin())

ans = 0



n.pop(-1)

for i in n:

    ans += int(i)

if ans % 9 == 0:

    print('Yes')

else:

    print("No")
import sys

cin = sys.stdin.readline

n = cin()

total = 0





for i in range(10):

    total += n.count(str(i)) * i

print(("Yes" if total%9 == 0 else "No"))
import sys

cin = sys.stdin.readline
n = list(cin())
ans = 0
n.pop(-1)
for i in n:
    ans += int(i)
if ans % 9 == 0:
    print("Yes")
else:
    print("No")

import sys

cin = sys.stdin.readline
n = cin()
total = 0
for i in range(10):
    total += n.count(str(i)) * i
print(("Yes" if total % 9 == 0 else "No"))

-n = list(cin()) -ans = 0 -n.pop(-1) -for i in n: -    ans += int(i) -if ans % 9 == 0: -    print("Yes") -else: -    print("No") +n = cin() +total = 0 +for i in range(10): +    total += n.count(str(i)) * i +print(("Yes" if total % 9 == 0 else "No"))