#include using namespace std; int main() { long long n; cin >> n; long long ans = INT64_MAX; for( long long j = 1; ; j++ ) { double p = (double)1/ j; double r = pow( n, p ); long long i = r; long long k = n - pow( i, j ); ans = min( ans, i + j + k ); if( k > i + j ) { i++; k = n - pow( i, j ); if( k >= 0 ) { ans = min( ans, i + j + k ); } i--; } if( i == 1 ) break; } cout << ans << endl; }