#coding: utf-8

from collections import defaultdict

import sys



N = eval(input())



s  = 0



for c in N:

    s += int(c)



if s % 9 == 0:

    print("Yes")

else:

    print("No")



N = eval(input())



s = sum(int(x) for x in N)

if s % 9 == 0:

    print("Yes")

else:

    print("No")
# coding: utf-8
from collections import defaultdict
import sys

N = eval(input())
s = 0
for c in N:
    s += int(c)
if s % 9 == 0:
    print("Yes")
else:
    print("No")

N = eval(input())
s = sum(int(x) for x in N)
if s % 9 == 0:
    print("Yes")
else:
    print("No")

-# coding: utf-8 -from collections import defaultdict -import sys - -s = 0 -for c in N: -    s += int(c) +s = sum(int(x) for x in N)