#include "bits/stdc++.h" using namespace std; bool P[20010] = {}; vector prime; int DP[20010] = {}; int main() { int N; cin >> N; for (int i = 2; i <= 20000; i++) P[i] = true; for (int i = 2; i * i <= 20000; i++) { if (P[i]) { for (int j = 2; i * j <= 20000; j++) { P[i * j] = false; } } } for (int i = 2; i <= 20000; i++) { if (P[i]) prime.push_back(i); } for (int i = 1; i <= 20000; i++) DP[i] = -1000000000; for (int X : prime) { for (int i = 20000 - X; i >= 0; i--) { DP[i + X] = max(DP[i + X], DP[i] + 1); } } if (DP[N] >= 0) cout << DP[N]; else cout << -1; }