def solve(N): primes = primes2(N) dp = [0] * (N + 1) dp[0] = 1 cumsum = 0 for p in primes: cumsum += p for i in range(min(cumsum, N), p - 1, -1): tmp = dp[i - p] if tmp and tmp + 1 > dp[i]: dp[i] = tmp + 1 return dp[N] - 1 N = int(input()) print(solve(N))