#include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; class Prime { public: vector prime_list; const ll MAX_N = 100000; Prime() { bool checked[MAX_N + 1]; memset(checked, false, sizeof(checked)); for (ll i = 2; i <= MAX_N; ++i) { if (!checked[i]) { prime_list.push_back(i); for (ll j = i * i; j <= MAX_N; j += i) { checked[j] = true; } } } } map prime_division(ll n) { map res; for (ll i = 0; prime_list[i] <= sqrt(n); ++i) { ll p = prime_list[i]; while (n % p == 0) { ++res[p]; n /= p; } } if (n != 1) { res[n] = 1; } return res; } bool is_prime(ll n) { if (n <= 1) return false; for (int i = 0; i < prime_list.size(); ++i) { if (n % prime_list[i]) return false; } return true; } }; int main() { ll N; Prime prime; cin >> N; ll min_T = LLONG_MAX; ll max_T = N - 1; map res = prime.prime_division(N); for (auto &[a, cnt] : res) { for (auto &[b, cnt] : res) { if (N % (a * b) != 0) continue; ll c = N / (a * b); ll t = (a + b + c) - 3; min_T = min(min_T, t); } } cout << min_T << " " << max_T << endl; return 0; }