n=int(input()) dp=[10**8]*(n+1) dp[1]=0 for i in range(1,n): for j in range(2,n+1): if i * j > n: break dp[i*j] = min(dp[i*j],dp[i]+j) print(dp[n])