def main(): N = int(input()) import math def sieve_of_eratosthenes(n): prime = [True]*(n+1) prime[0] = False prime[1] = False sqrt_n = math.ceil(math.sqrt(n)) for i in range(2, sqrt_n+1): if prime[i]: for j in range(2*i, n+1, i): prime[j] = False prime = [i for i in range(2, n + 1) if prime[i]] return prime num = sieve_of_eratosthenes(N) dp = [[-1]*(N+1) for _ in range(len(num))] dp[0][2] = 1 for i in range(1, len(num)): for j in range(2, N-num[i]+1): if dp[i-1][j] > 0: dp[i][j] = dp[i-1][j] if j + num[i] <= N and dp[i-1][j] > 0: dp[i][j+num[i]] = max(dp[i][j+num[i]], dp[i-1][j]+1) ans = -1 for i in range(len(num)): ans = max(ans, dp[i][N]) print(ans) if __name__ == '__main__': main()