#define _GLIBCXX_DEBUG #include using namespace std; int main() { long long N; cin >> N; vector S(9); S[2] = sqrt(N); for(int i = 3; i < 9; i++){ S[i] = sqrt(S[i-1]); } long long ans = 1000000000000000000; for(int i = 2; i < 9; i++){ if(S[i] == 1) break; long long T = N - pow(S[i],i); ans = min(ans, S[i]+i+T); } if(N < 4) ans = N; cout << ans << endl; }