def Eratosthenes(n): is_prime=[True] * (n+1) is_prime[0]=False is_prime[1]=False for i in range(2,int(n**0.5)+1): if not is_prime[i]: continue for j in range(i*2,n+1,i): is_prime[j]=False return [i for i in range(n+1) if is_prime[i]] def main(): n=int(input()) lis=Eratosthenes(n) N=len(lis) dp=[[-1]*(n+1) for _ in range(1+N)] dp[0][0]=0 for i in range(N): num=lis[i] for j in range(n+1): if dp[i][j]<0: continue if j+num<=n: dp[i+1][j+num]=max(dp[i+1][j+num],dp[i][j]+1) dp[i+1][j]=max(dp[i+1][j],dp[i][j]) print(dp[N][n]) if __name__=='__main__': main()