#include #include #include #include #include #include #include #include #include #include #include using namespace std; using namespace atcoder; typedef long long ll; #define rep(i,n) for (int i = 0; i < int(n);i++) int main(){ ll n; cin >> n; ll ans = 1e18; for (ll i = 1; i < 1e7;i++){ ll x = i; ans = min(ans,i+n-1); if (i == 1) continue; ll j = 1; while(x <= n){ ans = min(ans,i+j+n-x); j++; x*=i; } } cout << ans << endl; return 0; }