#include #define rep(i, n) for (int i = 0; i < (n); ++i) using std::cin; using std::cout; using std::min; using std::vector; using vi = vector; using vvi = vector; using ll = long long; int main() { ll n; cin >> n; ll ans = 1e18; for (ll i = 2; i * i <= n; ++i) { int k = log(n) / log(i); ans = min(ans, i + k + n - (ll)pow(i, k)); } cout << ans << '\n'; return 0; }