//#define _GLIBCXX_DEBUG #include #include #include using namespace std; using ll = long long; using pii = pair; using pll = pair; using vi = vector; using vvi = vector; using vl = vector; using vvl = vector; using vb = vector; using vvb = vector; using vpi = vector; using vvpi = vector; using vpl = vector; using vvpl = vector; const int inf = 1 << 30; const ll INF = 1LL << 60; #define rep(i,m,n) for (int i = m; i < (int)(n); i++) #define rrep(i,m,n) for (int i = m; i > (int)(n); i--) ll p(ll x,ll y){ ll ju = 1; rep(i,0,y){ if (ju > INF/double(x)) return INF; ju *= x; } return ju; } int main(){ ll n; cin >> n; ll ans = n; rep(i,2,61){ ll ok = 0,ng = floor(pow(n,1/(long double)(i)))+10; while (ng-ok > 1){ ll mid = (ok+ng)/2; if (p(mid,i) <= n) ok = mid; else ng = mid; } ll xt = pow(ok,i); ll ju = ok+i+n-xt; ans = min(ans,ju); } cout << ans << endl;; }