#include using namespace std; using ll = long long; int main(){ ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector dp(n + 1, -1); vector tb(n + 1); dp[0] = 0; for(int i = 2, s = 0; i <= n; i++){ if(tb[i])continue; for(int j = min(s, n - i); j >= 0; j--){ if(dp[j] >= 0)dp[j + i] = max(dp[j + i], dp[j] + 1); } for(int j = i << 1; j <= n; j += i){ tb[j] = true; } s += i; } cout << dp[n] << '\n'; }