def main(n: int):

    if n % 9 == 0:

        print('Yes')

    else:

        print('No')





if __name__ == '__main__':

    main(int(eval(input())))

def main():

    n = eval(input())

    res = 0

    for ni in n:

        res = (res + int(ni)) % 9



    print((('Yes', 'No')[res != 0]))





if __name__ == '__main__':

    main()

def main(n: int):
    if n % 9 == 0:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main(int(eval(input())))

def main():
    n = eval(input())
    res = 0
    for ni in n:
        res = (res + int(ni)) % 9
    print((("Yes", "No")[res != 0]))


if __name__ == "__main__":
    main()

-def main(n: int): -    if n % 9 == 0: -        print("Yes") -    else: -        print("No") +def main(): +    n = eval(input()) +    res = 0 +    for ni in n: +        res = (res + int(ni)) % 9 +    print((("Yes", "No")[res != 0])) -    main(int(eval(input()))) +    main()