#include #include #define for_int(i,a,b) for(int i=(a);i<=(b);++i) #define rep_int(i,a,b) for(int i=(a);i>=(b);--i) #define for_ll(i,a,b) for(ll i=(a);i<=(b);++i) #define rep_ll(i,a,b) for(ll i=(a);i>=(b);--i) #define Ios std::ios::sync_with_stdio(false),std::cin.tie(0) #define ull unsigned long long #define ll long long #define db double #define PII std::pair #define PLI std::pair template void chkmax(T& a, T b) { a > b ? (a = a) : (a = b); } template void chkmin(T& a, T b) { a > b ? (a = b) : (a = a); } template T min(T a, T b) { return a > b ? b : a; } template T max(T a, T b) { return a < b ? b : a; } template T abs(T a) { return a < 0 ? -a : a; } //using namespace std; /* 1.注意边界情况 2.优先考虑时间复杂度 !!! 3.求最大值时,答案应至多初始化为INT_MIN;求最小值时,答案应至少初始化为INT_MAX 4.遇事不决先暴力 5.代码要写简洁 6.计数题要开long long */ //快速IO template inline bool rd(T& ret) { char c; int sgn; if (c = getchar(), c == EOF) return 0; while (c != '-' && (c < '0' || c > '9')) c = getchar(); sgn = (c == '-') ? -1 : 1; ret = (c == '-') ? 0 : (c - '0'); while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0'); ret *= sgn; return true; } template inline void print(T x) { if (x > 9) print(x / 10); putchar(x % 10 + '0'); return; } using std::vector; using std::queue; using std::string; using std::map; using std::unordered_map; using std::priority_queue; using std::cout; using std::cin; long long n; long long res; int main() { rd(n); res = n; for (int i = 2;i <= min(n , 2000000ll) ; ++i) { int k = log(n) / log(i); long long tmp = 1, cnt = n; for (int j = 1; j <= k; ++j) { tmp *= i; chkmin(cnt, i + j + (n - tmp)); } chkmin(res, cnt); } print(res); puts(""); return 0; }