A=int(input()) if A%3==0: print("YES") else: print("NO")