#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define REP(i,a,b) for(int i=a;i<(int)b;i++) #define rep(i,n) REP(i,0,n) #define all(c) (c).begin(), (c).end() #define zero(a) memset(a, 0, sizeof a) #define minus(a) memset(a, -1, sizeof a) #define watch(a) { cout << #a << " = " << a << endl; } template inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); } template inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); } typedef long long ll; ll const inf = 1LL<<58; template vector divisors(T x) { vector ret; int p = 1; while((ll)p * p <= x) { if(x % p == 0) { ret.push_back(p); ret.push_back(x/p); } p ++; } sort(all(ret)); return ret; } int main() { ll N; cin >> N; ll ans = N - 1; auto D = divisors(N); for(int i=0; i < D.size() && (ll)D[i] * D[i] * D[i] <= N; i++) { for(int j=i; j < D.size() && (ll)D[i] * D[j] * D[j] <= N; j++) { if(N % (D[i] * D[j])) continue; ll k = N / D[i] / D[j]; minimize(ans, D[i] + D[j] + k - 3); } } cout << ans << " " << N - 1 << endl; return 0; }