#include using namespace std; using ll=long long; ll mypow(ll x,ll n){ ll res=1; while(n>0){ if(n&1){ res=res*x; } x=x*x; n>>=1; } return res; } int main(){ ll N; cin>>N; ll ans=N; ll j=2; while(mypow(2,j)<=N){ ll left=0,right=pow(N,(long double)1/j)+1; while(right-left>1){ ll mid=left+(right-left)/2; if(mypow(mid,j)>N){ right=mid; }else{ left=mid; } } ans=min(ans,left+j+N-mypow(left,j)); j++; } cout<