#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using ll = long long; using namespace std; typedef unsigned long long ull; typedef pair P; const ll MOD = 1000000007; const ll INF = 1 << 30; const ll INF2 = 9000000000000000000LL; const double INF3 = 900000000000000; const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 }; const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 }; #define ALL(x) (x).begin(),(x).end() bool bpr[20010]; void sieve(int n) { for (int i = 0;i <= n;i++)bpr[i] = true; bpr[0] = bpr[1] = false; for (int i = 2;i <= n;i++) { if (bpr[i]) for (int j = i * 2;j <= n;j += i)bpr[j] = false; } } int main() { int m, dp[20010] = { 0 }; vectorp; cin >> m; for (int i = 0;i <= 20010;i++)dp[i] = -1; dp[0] = 0; sieve(20010); for (int i = 0;i <= m;i++) { if (bpr[i])p.push_back(i); } for (int i = 0;i < p.size();i++) { for (int j = m;j >= 0;j--) { if (p[i] + j <= m&& dp[j] != -1)dp[p[i] + j] = max(dp[p[i] + j], dp[j] + 1); } } cout << dp[m] << endl; }