#ifndef LOCAL #include using namespace std; #define debug(...) (void(0)) #else #include "algo/debug.h" #endif #include void solve() { int N; cin >> N; vector P; P.reserve(3000); const int M = 20000; for (int i = 1; i <= min(M, N); i++) if (atcoder::internal::is_prime_constexpr(i)) P.push_back(i); vector dp(N + 1, -1); dp[0] = 0; for (unsigned i{}; i < P.size(); i++) { for (int j = N + 1; j >= 0; j--) if (j - P[i] >= 0 && dp[j - P[i]] != -1) { dp[j] = max(dp[j], dp[j - P[i]] + 1); } } cout << dp[N] << endl; } int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int tt = 1; // std::cin >> tt; while (tt--) { solve(); } }