def main():

    N = int(input())

    sum = 0

    for digit in str(N):

        sum += int(digit)



    print('Yes') if sum % 9 == 0 else print('No')





if __name__ == '__main__':

    main()

def main():

    N = int(input())

    print('Yes') if N % 9 == 0 else print('No')





if __name__ == '__main__':

    main()

def main():
    N = int(input())
    sum = 0
    for digit in str(N):
        sum += int(digit)
    print("Yes") if sum % 9 == 0 else print("No")


if __name__ == "__main__":
    main()

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


if __name__ == "__main__":
    main()

-    sum = 0 -    for digit in str(N): -        sum += int(digit) -    print("Yes") if sum % 9 == 0 else print("No") +    print("Yes") if N % 9 == 0 else print("No")