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