#include using namespace std; int main(){ long long n; cin >> n; long long ans = n + 1; for (int i = 1; i <= 60; i++){ long long tv = 0, fv = n + 1; while (fv - tv > 1){ long long mid = (tv + fv) / 2; long long P = 1; for (int j = 0; j < i; j++){ if (n / mid < P){ P = n + 1; break; } P *= mid; } if (P <= n){ tv = mid; } else { fv = mid; } } long long P = 1; for (int j = 0; j < i; j++){ P *= tv; } ans = min(ans, tv + i + (n - P)); } cout << ans << endl; }