""" Nをそれぞれ異なる素数の和で表すことができる場合, その中での最大の和の回数Mを出力してください。 dp[i] : iを異なる素数の和で表せるmax """ N = int(input()) INF = 10**10 U = 10**5 # is_prime = np.zeros(U,np.bool) #素数列挙(エラトステネス) is_prime = [0] * U is_prime[2] = 1 for i in range(3,U,2): is_prime[i] = 1 for p in range(3,U,2): if p*p > U: break if is_prime[p]: for i in range(p*p,U,p+p): is_prime[i] = 0 primes = [i for i,p in enumerate(is_prime) if p and i <= N] dp = [[-INF] * (N+1) for i in range(len(primes)+1)] dp[0][0] = 0 # print("len",len(primes)) for i in range(len(primes)): p = primes[i] dp[i+1][:] = dp[i][:] for j in range(N): if dp[i][j] == -INF : continue if j + p <= N: dp[i+1][j+p] = max(dp[i][j+p], dp[i][j] + 1) ans = dp[len(primes)][N] if ans == -INF: print(-1) else: print(ans)