#include #include #include using namespace std; bool is_prime(int n) { if (n <= 1) return false; for (int m = 2; m * m <= n; m++) { if (n % m == 0) return false; } return true; } int main() { int N; cin >> N; vector primes; for (int n = 2; n <= 20000; n++) { if (is_prime(n)) primes.emplace_back(n); } static int dp[30000]; memset(dp, -1, sizeof(dp)); dp[0] = 0; for (int p : primes) { for (int i = N; i >= 0; i--) { if (i - p < 0 or dp[i - p] < 0) continue; dp[i] = max(dp[i], dp[i - p] + 1); } } cout << dp[N] << endl; return 0; }