#include #include using namespace std; using LL = long long; using P = pair; using Graph = vector>; const long long LINF = 1LL << 60; #define all(x) (x).begin(), (x).end() #define rep(i,n) for(int i = 0; i < (n); ++i) templatevoid chmin(T&a, T b){if(a > b) a = b;} templatevoid chmax(T&a, T b){if(a < b) a = b;} int main(){ LL N; cin >> N; vector dp(N+1, LINF); dp[0] = 0; dp[1] = 0; for(int i = 1; i <= N; ++i){ for(int j = 2; j <= N; ++j){ if(i*j>N) break; chmin(dp[i*j], dp[i] + j); } } cout << dp[N] << endl; }