from sys import stdin, stdout, stderr def solve(): N = int(input()) ps = make_primes(N + 1) minf = -(len(ps) + 1) dp = [minf] * (N + 1) dp[0] = 0 for p in ps: for i in range(N, p - 1, -1): dp[i] = max(dp[i], dp[i - p] + 1) # print(dp) ans = dp[N] if ans > 0: print(ans) else: print(-1) def make_primes(N): sieve = [True] * N sieve[0] = sieve[1] = False for p in range(2, N): if not sieve[p]: continue for m in range(p**2, N, p): sieve[m] = False return [i for i in range(N) if sieve[i]] if __name__ == '__main__': solve()