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