//GIVE ME AC!!!!!!!!!!!!!!!!! //#pragma GCC target("avx") //#pragma GCC optimize("O3") //#pragma GCC optimize("unroll-loops") #include #define ll long long #define ld long double #define floatset() fixed<; using vi=vector; using vs=vector; using vc=vector; using vvl=vector; using P=pair; using vvc=vector; using vd=vector; using vp=vector

; using vb=vector; const int dx[8]={1,0,-1,0,1,-1,-1,1}; const int dy[8]={0,1,0,-1,1,1,-1,-1}; const ll inf=2e18; const ll MOD=1000000007; const ll mod=998244353; const double pi=acos(-1); template ostream &operator<<(ostream&os,const pair&p) { os< istream &operator>>(istream&is,pair&p) { is>>p.first>>p.second; return is; } template ostream &operator<<(ostream&os,const vector&v) { for(int i=0;i<(int)v.size();i++) { os< istream &operator>>(istream&is,vector&v) { for(T &in:v)is>>in; return is; } void scan(){} template void scan(Head&head,Tail&... tail) { cin>>head; scan(tail...); } template void print(const T &t) { cout << t << '\n'; } template void print(const Head &head, const Tail &... tail) { cout << head << ' '; print(tail...); } template void fin(const T &... a) { print(a...); exit(0); } template inline bool chmax(T1&a,T2 b){return a inline bool chmin(T1&a,T2 b){return a>b&&(a=b,true);} ll POW(ll a,ll n){ if(!n)return 1; if(n%2==1)return a*POW(a*a,n/2); return POW(a*a,n/2); } int main(){ LL(n); if(n<4)fin(n); ll ans=inf; rep(j,2,log2(n)+1){ ll i=pow(n,1.0/j); while(pow(i+1,j)<=n)i++; ll k=n-POW(i,j); chmin(ans,i+j+k); } fin(ans); }