#include #include #include #include #include #include #include #include #include #include #include #include #include #include #define int long long using namespace std; inline void sol() { int n; cin >> n; vector v; for (int i = 2; i * i <= n; i++) { if (n % i == 0) { v.push_back(i); if (i * i != n) { v.push_back(n / i); } } } sort(v.begin(), v.end()); int sz = v.size(); int ans = n - 1; for (int i = 0; i < sz; i++) { if (ans + 3 <= 2 * v[i]) break; for (int j = i; j < sz; j++) { int tmp = v[i] * v[j]; if (tmp > n) break; if (n % tmp) continue; tmp = n / tmp; ans = min(ans, v[i] + v[j] + tmp - 3); } } cout << ans << " " << n - 1 << "\n"; } signed main() { #ifdef ikun freopen("1.in", "r", stdin); freopen("1.out", "w", stdout); #endif ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); // init(); int T = 1; // cin >> T; while (T--) sol(); return 0; }