N = int(input()) ans = 0 while N>0: ans += N % 3 N //= 3 print('YNEOS'[ans%2::2])