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