#include using namespace std; vector divisors_2(long long n) { vector result; long long m = sqrt(n); for (long long i = m; i >= 1; i--) if (n % i == 0) { result.push_back(i); if (i != n / i) result.push_back(n / i); return result; } return result; } vector divisors(long long n) { vector result; for (long long i = 1; i * i <= n; i++) if (n % i == 0) { result.push_back(i); if (i != n / i) result.push_back(n / i); } sort(result.begin(), result.end()); return result; } int main() { long long n; cin >> n; long long mx = n - 1; long long mn = 1e18; for (long long p : divisors(n)) { long long qr = n / p; for (long long q : divisors_2(qr)) { long long r = qr / q; long long num = (p - 1) + (q - 1) + (r - 1); mx = max(mx, num); mn = min(mn, num); } } cout << mn << " " << mx << endl; }