#include #include #include #include #include #include #include #include #define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl; #define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } using namespace std; typedef long long ll; const ll INF = 2e18; ll pow(ll x, int n){ ll ans = 1; for(int i = 0; i < n; i++){ if(INF/x < ans) return INF; ans *= x; } return ans; } ll root_floor(ll n, ll k){ if(n == 1) return 1; if(k == 1) return n; ll l = 1, r = n; while(r-l > 1){ ll x = (l+r)/2; if(pow(x, k) > n) r = x; else l = x; } return l; } int main(){ ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(10) << fixed; ll n; cin >> n; ll ans = n; int x = 1; while(true){ ll r = root_floor(n, x); ll p = pow(r, x); ll i = r, j = x, k = n-p; chmin(ans, i+j+k); if(r == 1) break; x++; } cout << ans << endl; }