N = int(input()) ans = 0 while N > 0: ans += N % 3 N //= 3 if ans % 2: print("NO") else: print("YES")