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