#include using namespace std; #define rep(i, a) for (int i = 0; i < (a); i++) #define rep2(i, a, b) for (int i = (a); i < (b); i++) #define repr(i, a) for (int i = (a) - 1; i >= 0; i--) #define repr2(i, a, b) for (int i = (b) - 1; i >= (a); i--) template bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); } template bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); } typedef long long ll; long long modmul(long long a, long long b, long long mod) { long long ret = 0; for (; b > 0; a = a * 2 % mod, b /= 2) if (b & 1) ret = (ret + a) % mod; return ret; } long long modpow(long long a, long long b, long long mod) { long long ret = 1; for (; b > 0; a = modmul(a, a, mod), b /= 2) if (b & 1) ret = modmul(ret, a, mod); return ret; } bool isPrime(long long n) { if (n <= 1 || (n > 2 && n % 2 == 0)) return false; const int bases[] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37 }; int d = n - 1, s = 0; while (d % 2 == 0) s++, d /= 2; auto suspect = [&](ll a) { long long x = modpow(a, d, n); if (x == 1) return true; for (int r = 0; r < s; r++, x = modmul(x, x, n)) if (x == n - 1) return true; return false; }; for (int base : bases) if (base < n && !suspect(base)) return false; return true; } long long rho(long long n) { for (long long c = 1; c < n; c++) if (c != n - 2) { long long x = 2, y = 2, d = 1; auto f = [&](long long x) { return (modmul(x, x, n) + c) % n; }; while (d == 1) { x = f(x); y = f(f(y)); d = __gcd(abs(x - y), n); } if (d != n) return d; } return -1; } bool solve() { ll n; cin >> n; if (n == 1) return false; if (isPrime(n)) return false; ll r = rho(n); if (r == -1) return false; if (isPrime(r)) return !isPrime(n / r); return true; } int main() { cout << (solve() ? "YES" : "NO") << endl; return 0; }