def Base_10_to_n(X, n): if (int(X/n)): return Base_10_to_n(int(X/n), n)+str(X%n) return str(X%n) N = int(input()) num = str(Base_10_to_n(N,3)) count = 0 for n in num: n = int(n) count += n if count%2 == 0: print('YES') else: print('NO')