#include "bits/stdc++.h" using namespace std; typedef long long ll; const ll MOD = 1e9 + 7; bool is_prime[20001]; int dp[20001]; int main() { int N; cin >> N; memset(is_prime, -1, sizeof(is_prime)); for (int i = 2; i <= N; i++) { if (!is_prime[i]) continue; for (int j = i * 2; j <= N; j += i) is_prime[j] = 0; } vector prime; for (int i = 2; i <= N; i++) if (is_prime[i]) prime.push_back(i); memset(dp, -1, sizeof(dp)); dp[0] = 0; for (int i = 0; i < prime.size(); i++) { for (int j = N; j >= prime[i]; j--) { if (dp[j - prime[i]] != -1) dp[j] = max(dp[j], dp[j - prime[i]] + 1); } } cout << dp[N] << endl; }