A = int(input()) print(['YES','NO'][0 if A%3 == 0 else 1])