#include using namespace std; int main() { int N; cin >> N; int turn = 0; while( N ) { int n = 1; while( n * 3 <= N ) n *= 3; N -= n; turn = 1 - turn; } string ans = "NO"; if( turn == 0 ) ans = "YES"; cout << ans << endl; }