#if !__INCLUDE_LEVEL__ #include __FILE__ int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int N; cin >> N; const auto &e = eratosthenes(N); vi p; rep(i, 2, (int)e.size()) { if(e[i]) p.emplace_back(i); } vi dp(N + 1, -1); dp[0] = 0; for(int i = 0; i < (int)p.size(); i++) { for(int j = N; 0 <= j; j--) { if(j + p[i] <= N && dp[j] != -1) chmax(dp[j + p[i]], dp[j] + 1); } } print(dp[N]); return 0; } /* */ #else #include using namespace std; #include #include #include using namespace __gnu_pbds; template using Tree = tree; #define _GLIBCXX_DEBUG #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define rep(i, j, n) for(int i = j; i < n ; i++) template using V = vector; template using VV = V>; using ll = long long; using ld = long double; using pii = pair; using psi = pair; using pll = pair; using vb = V; using vi = V; using vd = V; using vc = V; using vs = V; using vll = V; using vld = V; using vvi = V; using vvd = V; using vvll = V; using vvld = V; using vvc = V; using vpii = V; //const int mod = 998244353; const int mod = 1000000007; const int inf = 1LL << 30; const ll infl = 1LL << 60; template bool chmax(T& a, const T &b) { if (a < b) { a = b; return true; } return false; } template bool chmin(T& a, const T &b) { if (a > b) { a = b; return true; } return false; } template void input(T&... a) { (cin >> ... >> a); } template void print(const T &a) { cout << a << '\n'; } template void print(const T& a, const Ts&... b) { cout << a; (cout << ... << (cout << ' ', b)); cout << '\n'; } template int lower(V &a, T &k) { int ok = a.size(), ng = -1; while(abs(ok - ng) > 1) { int mid = (ok + ng) / 2; if(a[mid] >= k) ok = mid; else ng = mid; } return ok; } template int upper(V &a, T &k) { int ok = a.size(), ng = -1; while(abs(ok - ng) > 1) { int mid = (ok + ng) / 2; if(a[mid] > k) ok = mid; else ng = mid; } return ok; } ll power(ll n, ll k) { ll res = 1; while(k) { if(k & 1) res *= n; n *= n; k >>= 1; } return res; } ll power_mod(ll n, ll k) { ll res = 1; while(k) { if(k & 1) res = res * n % mod; n = n * n % mod; k >>= 1; } return res; } bool is_prime(ll n) { if(n == 1) return 0; for(ll i = 2; i * i <= n; i++) if(n % i == 0) return 0; return 1; } V enum_divisors(ll n) { V res; for(ll i = 1; i * i <= n; i++) if(n % i == 0) { res.push_back(i); if(n / i != i) res.push_back(n / i); } sort(all(res)); return res; } V prime_factorize(ll n) { V res; for(ll i = 2; i * i <= n; i++) { if(n % i != 0) continue; ll ex = 0; while(n % i == 0) { ex++; n /= i; } res.push_back({i, ex}); } if(n != 1) res.push_back({n, 1}); return res; } vb eratosthenes(int n) { vb res(n + 1, 1); res[0] = 0, res[1] = 0; rep(i, 2, n + 1) if(res[i]) for(int j = 2 * i; j <= n; j += i) res[j] = 0; return res; } class FactorialMod { void calc_inverse() { inverse[0] = 0, inverse[1] = 1; rep(i, 2, max_num + 1) inverse[i] = mod - ((mod / i) * inverse[mod % i] % mod); } void calc_factorial_inverse() { factorial[0] = factorial_inverse[0] = 1; rep(i, 1, max_num + 1) { factorial[i] = (factorial[i - 1] * i) % mod; factorial_inverse[i] = (factorial_inverse[i - 1] * inverse[i]) % mod; } } public: int max_num; vll inverse; vll factorial; vll factorial_inverse; FactorialMod(int _max_num) { max_num = _max_num, inverse = vll(max_num + 1), factorial = vll(max_num + 1), factorial_inverse = vll(max_num + 1), calc_inverse(), calc_factorial_inverse(); } ll conbination_mod(int n, int k) { if(min(n, k) < 0 || max(n, k) > max_num || k > n) return 0; return (((factorial[n] * factorial_inverse[k]) % mod) * factorial_inverse[n - k]) % mod; } ll multi_choose_mod(int n, int k) { return conbination_mod(n + k - 1, k); } }; #endif