#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define all(x) (x).begin(),(x).end() #define rep(i,m,n) for(int i = m;i < n;++i) #define pb push_back #define fore(i,a) for(auto &i:a) #define rrep(i,m,n) for(int i = m;i >= n;--i) #define INF INT_MAX/2 using namespace std; using ll = long long; using R = double; using Data = pair>; const ll MOD = 1e9 + 7; const ll inf = 1LL << 50; struct edge { ll from; ll to; ll cost; }; vectorpr; int memo[20202]; int used[20202]; bool prime(ll n) { if (n == 1) { return false; } for (ll i = 2; i*i <= n; i++) { if (n%i == 0) { return false; } } return true; } void pri(int *x) { rep(i,0,11) { cout << " " << x[i]; } cout << endl; } int main() { int n; cin >> n; rep(i, 0, n + 1)memo[i] = -1; for (int i = 2; i <= n; i++)if (prime(i))pr.pb(i); memo[0] = 0; fore(x, pr) { for (int i = 0; i <= n; i++) { if (memo[i] == -1)continue; if (i+x <= n && used[i] == 0) { if (memo[i + x] < memo[i] + 1)used[i + x] = 1; memo[i + x] = max(memo[i + x], memo[i] + 1); } } memset(used, 0, sizeof(used)); } cout << memo[n] << endl; return 0; }