#include using namespace std; using ll = long long; #define FOR(i,a,b) for(ll i=(a);i<(b);++i) #define ALL(v) (v).begin(), (v).end() #define p(s) cout<<(s)<> N; // a<=b<=cとしてよい ll min_ans = inf; for(int a=1; a*a*a<=N; a++){ if(N%a==0){ ll M = N/a; for(int b=a; b*b<=M; b++){ if(M%b==0){ ll c = M/b; ll ans = a+b+c-3; min_ans = min(min_ans, ans); } } } } p2(min_ans, N-1); return 0; }