import sys



readline = sys.stdin.readline

MOD = 10 ** 9 + 7

INF = float('INF')

sys.setrecursionlimit(10 ** 5)





def main():

    n = eval(input())

    cur = 0



    for x in n:

        cur += int(x)



    if cur % 9 == 0:

        print("Yes")

    else:

        print("No")





if __name__ == '__main__':

    main()

n = eval(input())

cur = 0



for x in n:

    cur += int(x)



if cur % 9 == 0:

    print("Yes")

else:

    print("No")

import sys

readline = sys.stdin.readline
MOD = 10**9 + 7
INF = float("INF")
sys.setrecursionlimit(10**5)


def main():
    n = eval(input())
    cur = 0
    for x in n:
        cur += int(x)
    if cur % 9 == 0:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

n = eval(input())
cur = 0
for x in n:
    cur += int(x)
if cur % 9 == 0:
    print("Yes")
else:
    print("No")

-import sys - -readline = sys.stdin.readline -MOD = 10**9 + 7 -INF = float("INF") -sys.setrecursionlimit(10**5) - - -def main(): -    n = eval(input()) -    cur = 0 -    for x in n: -        cur += int(x) -    if cur % 9 == 0: -        print("Yes") -    else: -        print("No") - - -if __name__ == "__main__": -    main() +n = eval(input()) +cur = 0 +for x in n: +    cur += int(x) +if cur % 9 == 0: +    print("Yes") +else: +    print("No")