#include #include #include using namespace std; #define REP(i, a, n) for(int i=a; i prime; void crate_prime(int n) { vector p; p.resize(n + 1, true); p[0] = p[1] = false; for (int i = 2; i*i <= n; i++) { if (p[i]) { for (int j = 2 * i; j < n; j += i) p[j] = false; } } REP(i, 2, n) if (p[i]) prime.push_back(i); } int dp[2270][20001]; int main() { int N; cin >> N; crate_prime(N); REP(i, 0, 2270) REP(j, 0, 20001) dp[i][j] = -1; dp[0][0] = 0; REP(i, 0, prime.size()) { REP(j, 0, N + 1) { if (dp[i][j] >= 0) { dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]); dp[i + 1][j + prime[i]] = max(dp[i + 1][j + prime[i]], dp[i][j] + 1); } } } cout << dp[(int)prime.size()][N] << endl; return 0; }