N=int(input()) x=N import math L=math.floor(math.sqrt(x)) # 平方根を求める Primelist=[i for i in range(x+1)] Primelist[1]=0 # 1は素数でないので0にする. for i in Primelist: if i>L: break if i==0: continue for j in range(2*i,x+1,i): Primelist[j]=0 Primes=[Primelist[j] for j in range(x+1) if Primelist[j]!=0] Primes.reverse() DP=[[-1]*1000 for i in range(N+1)] def calc(N,i): if DP[N][i]!=-1: return DP[N][i] if N==0: return 0 if i>=len(Primes) or Primes[i]>N: return -1<<60 ANS=0 for j in range(i,len(Primes)): if N-Primes[j]>=0: ANS=max(ANS,calc(N-Primes[j],j+1)+1) DP[N][i]=ANS return ANS print(calc(N,0))