#include #define rep(i,n) for(int i=(0);i<(n);i++) using namespace std; typedef long long ll; template bool chmax(T &a, const T &b) { if (a bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; } int main(){ cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vector isprime(20001, true); isprime[0] = false; isprime[1] = false; for(int i = 2; i <= 20000; i++){ if(isprime[i]){ for(int j = i + i; j <= 20000; j += i){ isprime[j] = false; } } } vector primes; rep(i, 20001) if(isprime[i]) primes.push_back(i); int m = primes.size(); int dp[2][n+1]; int INF = 1e8; rep(i, 2) rep(j, n+1) dp[i][j] = -1; dp[0][n] = 0; rep(i, m) { rep(j, n+1) dp[(i+1)%2][j] = -1; int p = primes[i]; rep(j, n+1){ chmax(dp[(i+1)%2][j], dp[i%2][j]); if(j-p >= 0 && dp[i%2][j] != -1) chmax(dp[(i+1)%2][j-p], dp[i%2][j] + 1); } } cout << dp[n%2][0] << endl; }