#include <iostream>
using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    int c = 0;
    while(n){
        c += n % 3;
        n /= 3;
    }
    if(c % 2) cout << "NO" << endl;
    else cout << "YES" << endl;
}