import math N=int(input()) S=[] maxv=N+10 def eratos(n): isprime=[True]*(n+1) isprime[0]=False isprime[1]=False for i in range(2,int(math.sqrt(n))+1): if isprime[i]==True: j=i+i while j<=n: isprime[j] =False j=j+i for i in range(n+1): if isprime[i]==True: S.append(i) return S sosu=eratos(N) #print(sosu) #print(len(sosu)) DP = [[-1]*(maxv) for i in range(len(S)+1)] for i in range(len(S)+1): DP[i][0]=0 for i in range(len(S)): for j in range(maxv): if j+S[i]<=N and DP[i][j]!=-1: DP[i+1][j+S[i]]=DP[i][j]+1 DP[i+1][j]=max(DP[i][j],DP[i+1][j]) ans=-1 for i in range(len(S)+1): if DP[i][N]>ans: ans=DP[i][N] if ans>0: print(ans) else: print(-1) #print(DP)