#include using namespace std; using ll = long long; int main(){ ll n; cin >> n; if(n < 4LL){ cout << n << endl; }else{ ll ans = LLONG_MAX; for(ll j = 2; j <= log2(n); j++){ ll i = pow(n, 1.0 / j); ll k = n - pow(i, j); ans = min(ans, i + j + k); } cout << ans << endl; } }