#define _CRT_SECURE_NO_WARNINGS #include"bits/stdc++.h" #define INF 1e9 #define INFLL 1e18 #define EPS 1e-9 #define MOD 1000000007 #define REP(i,n) for(ll i=0,i##_len=(n);i=0;--i) #define REPR1(i,n) for(ll i=(n);i>0;--i) #define REPC(i,obj) for(auto i:obj) #define ALL(obj) (obj).begin(),(obj).end() #define SETP(n) cout<>(h,vector(w)) #define VVI(T,h,w,i) vector>(h,vector(w,i)) using namespace std; using ll = long long; templateinline T in() { T ret; cin >> ret; return ret; } int main() { vectoris_prime(20001, true); is_prime[0] = is_prime[1] = false; REP(i, 150) { if (is_prime[i]) { for (ll j = i * 2; j < 20001; j += i) { is_prime[j] = false; } } } vectorprime; REP(i, 20001)if (is_prime[i])prime.push_back(i); //REPC(p, prime)cout << p << endl; ll n = in(); auto dp = VVI(ll, prime.size() + 1, n + 1, -1); dp[0][0] = 0; REP(i, prime.size()) { REP(j, n + 1) { dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]); if (j >= prime[i]) dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - prime[i]] + 1); } } ll res = dp[prime.size()][n]; cout << (res < 2 ? -1 : res) << endl; }