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