#include using namespace std; using ll = long long; #define rep(i,m,n) for(int i=m; i bool chmin(T& a, T b){ if(a > b){a = b; return true;} return false; } template bool chmax(T& a, T b){ if(a < b){a = b; return true;} return false; } template T gcd(T a, T b){ return a % b ? gcd(b, a % b) : b; } template T lcm(T a, T b){ return a / gcd(a, b) * b; } ll n; ll power(ll x, ll y){ ll res = 1LL; rep(i, 0, y){ if(double(res * x) > double(n)) return -1LL; res *= x; } return res; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n; ll ans = n; // (i, j, k) = (1, 0, n-1) for(ll j = 2LL; (1LL << j) <= n; ++j){ ll lo = 0LL, hi = ll(1e9 + 100), mid; while(abs(lo - hi) > 1LL){ mid = (lo + hi) / 2LL; if(power(mid, j) == -1 || power(mid, j) > n) hi = mid; else lo = mid; } ll k = n - power(lo, j); // cout << lo << ' ' << j << ' ' << k << endl; chmin(ans, lo + j + k); } cout << ans << endl; return 0; }