def main():

    N = eval(input())

    ans = 0

    for ch in N:

        ans += int(ch)



    if ans % 9 == 0:

        print("Yes")

    else:

        print("No")





if __name__ == "__main__":

    main()

def main():

    N = eval(input())

    sum_all_digits = 0



    for ch in N:

        sum_all_digits += int(ch)



    if sum_all_digits % 9 == 0:

        ans = "Yes"

    else:

        ans = "No"



    print(ans)





if __name__ == "__main__":

    main()

def main():
    N = eval(input())
    ans = 0
    for ch in N:
        ans += int(ch)
    if ans % 9 == 0:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

def main():
    N = eval(input())
    sum_all_digits = 0
    for ch in N:
        sum_all_digits += int(ch)
    if sum_all_digits % 9 == 0:
        ans = "Yes"
    else:
        ans = "No"
    print(ans)


if __name__ == "__main__":
    main()

-    ans = 0 +    sum_all_digits = 0 -        ans += int(ch) -    if ans % 9 == 0: -        print("Yes") +        sum_all_digits += int(ch) +    if sum_all_digits % 9 == 0: +        ans = "Yes" -        print("No") +        ans = "No" +    print(ans)