#include using namespace std; typedef long long ll; typedef long double ld; typedef pair P; typedef pair l_l; typedef vector vi; typedef vector vvi; typedef vector vl; typedef vector

vp; #define fi first #define se second #define rep(i,n) for(int i = 0; i < (n); ++i) #define rrep(i,n) for(int i = 1; i <= (n); ++i) #define drep(i,n) for(int i = (n)-1; i >= 0; --i) const int INF=1001001000; const int mINF=-1001001000; const ll LINF=1010010010010010000; template inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } //グリッド:(典型)dp,dfs,bfs,最短経路,その他 vector isprime(20010,true); void eratos(int max_n){ for(int i=2;i*i<=max_n;i++){ if(isprime[i]){ for(int j=2*i;j<=max_n;j+=i){ isprime[j]=false; } } } } int main(){ int n;cin >> n; vector prime; eratos(20010); for(int i=2;i<=20010;i++){ if(isprime[i]) prime.push_back(i); } vi dp(20010,-1); dp[0]=0; for(auto p:prime){ for(int j=n;j>=0;j--){ if(p+j<=n&&dp[j]!=-1){ chmax(dp[p+j],dp[j]+1); } } } cout << dp[n] << endl; return 0; }