import math def factorize(n): factors = {} while n % 2 == 0: factors[2] = factors.get(2, 0) + 1 n = n // 2 i = 3 while i * i <= n: while n % i == 0: factors[i] = factors.get(i, 0) + 1 n = n // i i += 2 if n > 1: factors[n] = 1 return factors def generate_divisors(factors): divisors = [1] for p, exp in factors.items(): current_length = len(divisors) for e in range(1, exp + 1): pe = p ** e for i in range(current_length): divisors.append(divisors[i] * pe) divisors = list(set(divisors)) divisors.sort() return divisors def get_factors_a(a, original_factors): factors_a = {} for p in original_factors: count = 0 temp = a while temp % p == 0 and temp > 0: count += 1 temp = temp // p if count > 0: factors_a[p] = count return factors_a def subtract_factors(original_factors, factors_a): factors_m = {} for p in original_factors: exp = original_factors[p] - factors_a.get(p, 0) if exp > 0: factors_m[p] = exp return factors_m def main(): N = int(input().strip()) if N == 1: print("0 0") return factors = factorize(N) divisors = generate_divisors(factors) a_candidates = [] for a in divisors: if a ** 3 <= N: a_candidates.append(a) min_sum = float('inf') for a in a_candidates: M = N // a factors_a = get_factors_a(a, factors) factors_m = subtract_factors(factors, factors_a) divisors_m = generate_divisors(factors_m) sqrt_m = int(math.isqrt(M)) for b in divisors_m: if b < a or b > sqrt_m: continue if M % b != 0: continue c = M // b if c < b: continue current_sum = a + b + c if current_sum < min_sum: min_sum = current_sum Tmin = min_sum - 3 Tmax = N - 1 print(f"{Tmin} {Tmax}") if __name__ == "__main__": main()