#include #define PN 2270 using namespace std; int N, PC = 0; int prime[PN] = {0}; int dp[20001] = {0}; int main(void){ cin >> N; int i, j, k; prime[PC++] = 2; for(i = 3; i <= N; i += 2){ k = 0; for(j = 3; j <= sqrt(i); j += 2){ if(i % j == 0){ k = 1; break; } } if(k == 0) prime[PC++] = i; } memset(dp, -1, sizeof(dp)); dp[0] = 0; for(i = 0; i < PC; ++i){ for (int j = N; j >= 0; --j){ k = prime[i] + j; if(k <= N && dp[j] != -1){ dp[k] = (dp[k] < dp[j] + 1) ? dp[j] + 1 : dp[k]; } } } cout << dp[N] << endl; return 0; }