#include using namespace std; bool prime[20002]; int dp[20002]; int n; int main() { cin >> n; for(int i = 2; i <= n; i++) { if(prime[i]) continue; for(int j = i + i; j <= n; j += i) { prime[j] = true; } } fill(dp,dp+n+1,-1); dp[0] = 0; for(int i = 2; i <= n; i++) { if(prime[i]) continue; for(int j = n; j >= 0; j--) { if(j + i > n || dp[j] < 0) continue; dp[j+i] = max(dp[j+i],dp[j] + 1); } } if(dp[n]) cout << dp[n] << endl; else cout << -1 << endl; }