c[20001],d[20001],j;main(i,n){for(*d=scanf("%d",&n);i++<=n;)if(!c[i]){for(j=n;j>=i;--j)d[j-i]?d[j]=fmax(d[j],d[j-i]+1):0;for(j=i;j<=n;c[j+=i]=1);}j=!printf("%d",d[n]-1);}