#include int prime[20001]; int p[2262]; int dp[2263][20001]; main(){ for(int i = 2;i*i <= 20000;i++){ if(prime[i])continue; for(int j = i*2;j <= 20000;j+=i){ prime[j] = 1; } } int count = 0; for(int i = 2;i <= 20000;i++){ if(prime[i])continue; p[count] = i; count++; } for(int i = 0;i < 2262;i++){ for(int j = 0;j <= 20000;j++){ dp[i+1][j] = dp[i][j]; if(j < p[i])continue; if(j-p[i]==0){ dp[i+1][j] = std::max(dp[i][j],1); }else if(dp[i][j-p[i]]!=0){ dp[i+1][j] = std::max(dp[i][j],dp[i][j-p[i]]+1); } } } int N; scanf("%d",&N); printf("%d\n",dp[2262][N]?dp[2262][N]:-1); }