#include using namespace std; long long n, m = 1e18; int main() { cin >> n; for (long long i = 2; i <= sqrt(n); i++) { int j = 1; long long u = i; while (u <= n / i) { u *= i; j++; } m = min(m, i + j + n - u); if (n - u < i) break; } cout << m << endl; }