N=list(eval(input()))

NN=[int(t) for t in N]

T=sum(NN)

if T%9==0:

    print("Yes")

else :

    print("No")
N=list(eval(input()))

S=[int(t) for t in N]

T=sum(S)

if T%9==0:

  print("Yes")

else :

  print("No")
N = list(eval(input()))
NN = [int(t) for t in N]
T = sum(NN)
if T % 9 == 0:
    print("Yes")
else:
    print("No")

N = list(eval(input()))
S = [int(t) for t in N]
T = sum(S)
if T % 9 == 0:
    print("Yes")
else:
    print("No")

-NN = [int(t) for t in N] -T = sum(NN) +S = [int(t) for t in N] +T = sum(S)