#include using namespace std; #define _p(...) (void)printf(__VA_ARGS__) #define forr(x,arr) for(auto&& x:arr) #define _overload3(_1,_2,_3,name,...) name #define _rep2(i,n) _rep3(i,0,n) #define _rep3(i,a,b) for(int i=int(a);i=int(a);i--) #define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__) #define all(x) (x).begin(), (x).end() #define bit(n) (1LL<<(n)) #define sz(x) ((int)(x).size()) #define fst first #define snd second using ll=long long;using pii=pair; using vb=vector;using vs=vector; using vi=vector;using vvi=vector;using vvvi=vector; using vl=vector;using vvl=vector;using vvvl=vector; using vd=vector;using vvd=vector;using vvvd=vector; using vpii=vector;using vvpii=vector;using vvvpii=vector; templateT read(){T t;cin>>t;return t;} templateostream&operator<<(ostream&o,const pair&p){o<<'('< sieve(int n) { vector ret; if (n <= 2) return ret; vector ok(n / 2, true); ret.push_back(2); for (int i = 3; i < n; i += 2) { int i2 = i / 2; if (!ok[i2]) continue; ret.push_back(i); for (int j = i2 + i; j < n / 2; j += i) ok[j] = false; } return ret; } template bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } int solve() { int n = read(); auto ps = sieve(n+1); int m = sz(ps); vi dp(n+1, -1); dp[0] = 0; rep(i, m) { int p = ps[i]; rrep(j, n) if (dp[j] >= 0) { if (j+p <= n) { amax(dp[j+p], dp[j] + 1); } } } return dp[n]; } void Main() { cout << solve() << endl; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); Main(); return 0; }