#include using namespace std; long long n, m, w = 1; const long long INF = 1000000000000000007; long long kpow(long long a, long long b) { long long u = 1, v = a; while (b > 0) { if (b & 1) { if (u > INF / v) return INF; u *= v; } b >>= 1; if (b > 0 && v > INF / v) return INF; v = v * v; } return u; } long long ksqrt(long long n, long long k) { long long l = 1, r = n; while (r > l + 1) { long long m = (l + r) / 2, u = kpow(m, k); if (u > n) r = m; else l = m; } return l; } int main() { cin >> n; m = n; while ((1ull << w) <= n) w++; for (int j = 2; j < w; j++) { long long i = ksqrt(n, j), u = kpow(i, j); m = min(m, i + j + n - u); } cout << m << endl; }