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