#include using namespace std; int INF = 1000000; int main(){ long long A; cin >> A; A--; long long ans = INF; for (int i = 2; i < 100; i++){ long long B = A; long long tmp = 0; while (B > 0){ B /= i; tmp += i; } ans = min(ans, tmp); } for (int i = 1; i <= 100; i++){ long long tmp = pow(A, (double) 1 / i); tmp = max(tmp - 2, (long long) 0); while (1){ long long tmp2 = 1; for (int j = 0; j < i; j++){ tmp2 *= tmp; } if (tmp2 < A){ tmp++; } else { break; } } if (tmp > 1){ ans = min(ans, tmp * i); } } cout << ans << endl; }