#include #include #include using namespace std; int prime[20001]; void eratosthenes(int n) { for (int i = 1; i <= n; i++) { prime[i] = 1; } prime[1] = 0; for (int i = 2; i <= n / 2; i++) { for (int j = 2; i * j <= n; j++) { prime[i*j] = 0; } } } int main() { int n, dp[20001]; vector P; cin >> n; for (int i = 1; i <= n; i++) { dp[i] = -1; } dp[0] = 0; eratosthenes(n); for (int i = 1; i <= n; i++) { if (prime[i] == 1) { P.push_back(i); } } for (auto i : P) { for (int j = n; j >= 0; j--) { if (i + j <= n && dp[j] != -1) { dp[i + j] = max(dp[i + j], dp[j] + 1); } } } cout << dp[n] << endl; }