def main():

    N = int(input())

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





if __name__ == '__main__':

    main()

def main():

    N = str(input())

    M = list(map(int, N))

    S = sum(M)

   

    print('Yes') if S % 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 = str(input())
    M = list(map(int, N))
    S = sum(M)
    print("Yes") if S % 9 == 0 else print("No")


if __name__ == "__main__":
    main()

-    N = int(input()) -    print("Yes") if N % 9 == 0 else print("No") +    N = str(input()) +    M = list(map(int, N)) +    S = sum(M) +    print("Yes") if S % 9 == 0 else print("No")