#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+1) if (p[i]) prime.push_back(i); } int dp[2270][20101]; int main() { int N; cin >> N; crate_prime(N+1); REP(i, 0, 2270) REP(j, 0, 20101) dp[i][j] = -1; dp[0][0] = 0; REP(i, 0, (int)prime.size()) { REP(j, 0, N + 1) { if (dp[i][j] >= 0) { dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]); if(j+prime[i] < 20101) 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; }