# include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include using namespace std; using LL = long long; using ULL = unsigned long long; constexpr int INF = 2000000000; constexpr int HINF = INF / 2; constexpr double DINF = 100000000000000000.0; constexpr long long LINF = 9223372036854775807; constexpr long long HLINF = 4500000000000000000; const double PI = acos(-1); int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 }; #define ALL(x) (x).begin(),(x).end() #define UNIQ(c) (c).erase(unique(ALL((c))), end((c))) #define mp make_pair #define eb emplace_back typedef pair P; typedef pair PP; int n, dp[20202]; vector prime; void MakePrime(int n) { prime.emplace_back(2); for (int i = 3; i < n; i += 2) { bool a = false; for (int j = 3; j <= std::sqrt(i); j += 2) { if (i%j == 0) { a = true; } } if (a == false) { prime.emplace_back(i); } } } int main() { cin >> n; for (int i = 0; i < 20202; i++)dp[i] = -1; dp[0] = 0; MakePrime(20000); for (int i = 0; i < prime.size(); i++) { for (int j = n; j >= 0; j--) { if (j + i <= n&&dp[j] != -1)dp[prime[i]+j] = max(dp[prime[i] + j], dp[j] + 1); } } cout << dp[n] << endl; }