#include using namespace std; typedef long long ll; typedef long int li; typedef long double lb; #define rep(i,j,n) for (ll i = j; i < (n); i++) #define all(x) (x).begin(),(x).end() #define CLR(mat,f) memset(mat, f, sizeof(mat)) #define IN(a, b, x) (a<=x&&x inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } typedef pairP; const ll mod=1e9+7; const int INF = 1000000; const double PI=3.14159265359; int main(){ ll n;cin>>n; bool is_prime[n+1];CLR(is_prime,true); is_prime[0]=is_prime[1]=false; vectorprime; for(ll i=2;i<=n;i++){ if(is_prime[i]){ prime.push_back(i); for(ll j=2;i*j<=n;j++){ is_prime[i*j]=false; } } } ll dp[20002]; CLR(dp,-1); dp[0]=0; rep(i,0,prime.size()){ for(ll j=n;j>=prime[i];j--){ if(dp[j-prime[i]]!=-1)chmax(dp[j],dp[j-prime[i]]+1); } } out(dp[n]); return 0; }