import itertools def isqrt(n): x = n y = (x + 1) // 2 while y < x: x = y y = (x + n // x) // 2 return x N = int(input()) div = [i for i in range(1, isqrt(N) + 1) if not N % i] Nmin = Nmax = N - 1 for i, j in itertools.combinations_with_replacement(div, 2): if not N % (i * j): Nmin = min(Nmin, i + j + (N // (i * j)) - 3) print(Nmin, Nmax)