#include typedef long long ll; const int maxn = 1e18; ll qmi(ll a, ll k) { ll res = 1; while (k) { if (k & 1) res = (ll)res * a; k >>= 1; a = (ll)a * a; }return res; } int main() { ll n; scanf("%lld", &n); if (n <= 4) {std::cout << n << "\n"; return 0;} ll ans = 1e18; for (ll j = 2; j <= 60; j ++) { ll i = qmi(n, 1.0 / j); while (qmi(i + 1, j) <= n) i ++; ll k = n - qmi(i, j); ans = std::min(ans, i + j + k); } std::cout << ans << "\n"; return 0; }