#include using namespace std; bool isPrime(int n) { for (int i = 2; i * i <= n; i++) { if (n % i == 0) { return false; } } return n >= 2; } int dp[20001]; int main() { for (int i = 0; i <= 20000; i++) { dp[i] = -20000; } dp[0] = 0; for (int i = 2; i <= 20000; i++) { if (isPrime(i)) { for (int j = 20000 - i; j >= 0; j--) { dp[i + j] = max(dp[i + j], dp[j] + 1); } } } int n; cin >> n; cout << max(-1, dp[n]) << endl; }