#include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; const int INF = 100000; int prime[10000]; int dp[1000][20005]; bool is_prime[100000]; int func(int n){ int p = 0; for (int i = 0; i <= n; i++) is_prime[i] = true; is_prime[0] = is_prime[1] = false; for (int i = 2; i <= n; i++){ if (is_prime[i]){ prime[p++] = i; for (int j = 2 * i; j <= n; j += i) is_prime[j] = false; } } return p; } int main(void){ int n; cin >> n; int s = func(n); memset(dp, -1,sizeof(dp)); dp[0][0] = 0; for (int i = 0; i < s; i++){ for (int j = 0; j <= n; j++){ dp[i + 1][j] = dp[i][j]; if (prime[i] <= j&&dp[i][j - prime[i]] != -1){ dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - prime[i]] + 1); } } } cout << dp[s][n] << endl; }