#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(i, n) for (int i = 0; i < (n); i++) #define rrep(i, n) for (int i = (n) - 1; i >= 0; i--) #define reps(i, n) for (int i = 1; i <= (n); i++) #define repi(i, a, b) for (int i = (a); i < (b); i++) #define all(a) (a).begin(), (a).end() #define bit(b) (1ull << (b)) using namespace std; using i32 = long long; using u32 = unsigned long long; using i64 = long long; using u64 = unsigned long long; using f64 = double; using vi32 = vector; using vu32 = vector; using vi64 = vector; using vu64 = vector; using vf64 = vector; using vstr = vector; using vvi32 = vector; using vvu32 = vector; using vvi64 = vector; using vvu64 = vector; using vvf64 = vector; template void amax(T &x, S y) { if (x < y) x = y; } template void amin(T &x, S y) { if (y < x) x = y; } i64 dp[20010]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(16); vi32 primes; for (int i = 2; i <= 20000; i++) { bool flag = true; for (int j = 2; j * j <= i; j++) { if (i % j == 0) flag = false; } if (flag) primes.push_back(i); } int n; cin >> n; rep(i, 20010) dp[i] = -1e9; dp[0] = 0; rep(j, primes.size()) { rrep(i, 20000) { if (i + primes[j] > 20000) continue; if (dp[i] < 0) continue; amax(dp[i + primes[j]], dp[i] + 1); } } if (dp[n] < 0) cout << -1 << endl; else cout << dp[n] << endl; return 0; }