N = str(eval(input()))

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

else:

    if int(N) == 0 :print("Yes")

    else:

        sum = 0

        for i in range(0,len(N)):

           sum += int(N[i])

        if sum%9 == 0: print("Yes")

        else: print("No")
N = str(eval(input()))

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

else:

    if int(N) == 0 :print("Yes")

    else:

        sum = 0

        for ki_tu in N:

           sum += int(ki_tu)

        if sum%9 == 0: print("Yes")

        else: print("No")
N = str(eval(input()))
if int(N) % 9 != 0:
    print("No")
else:
    if int(N) == 0:
        print("Yes")
    else:
        sum = 0
        for i in range(0, len(N)):
            sum += int(N[i])
        if sum % 9 == 0:
            print("Yes")
        else:
            print("No")

N = str(eval(input()))
if int(N) % 9 != 0:
    print("No")
else:
    if int(N) == 0:
        print("Yes")
    else:
        sum = 0
        for ki_tu in N:
            sum += int(ki_tu)
        if sum % 9 == 0:
            print("Yes")
        else:
            print("No")

-        for i in range(0, len(N)): -            sum += int(N[i]) +        for ki_tu in N: +            sum += int(ki_tu)