# 3進数 n = int(input()) num = n res = [] while num: res.append(num % 3) num //= 3 goukei = sum(res) if goukei % 2 == 0: print("YES") else: print("NO")