#include <stdio.h>
#include <vector>
using namespace std;

long long getJiecheng(long long a) { //求a的阶乘
    if (a == 0) {
        return 1;
    }
    if (a == 1) {
        return 1;
    }
    return a * getJiecheng(a - 1);
}

void dfs(int counts, vector<long long> vec, long long n, long long i,
         long long sum, bool& isExsit) {
    if (isExsit) {
        return;
    }
    if (sum == n) {
        isExsit = true;
        return;
    }
    if (i >= counts || sum > n) {
        return;
    }
    sum += vec[i];
    dfs(counts, vec, n, i + 1, sum, isExsit);
    sum -= vec[i];
    dfs(counts, vec, n, i + 1, sum, isExsit);
}

int main() {

    long long n;
    while (scanf("%lld", &n) != EOF) {
        vector<long long> vec;
        int counts = 0;
        for (long long i = 0;; i++) {
            long long t = getJiecheng(i);
            if (t > n) {
                break;
            }
            vec.push_back(t);
            counts++;
        }
        bool isExsit = false;
        dfs(counts, vec, n, 0, 0, isExsit);
        if (!isExsit || n == 0) {
            printf("NO\n");
        } else {
            printf("YES\n");
        }
    }
    return 0;
}