local n = io.read("*n") local mce, mfl, msq, mmi = math.ceil, math.floor, math.sqrt, math.min local tbli = table.insert local function getprimes(x) local primes = {} local allnums = {} for i = 1, x do allnums[i] = true end for i = 2, x do if(allnums[i]) then tbli(primes, i) local lim = mfl(x / i) for j = 2, lim do allnums[j * i] = false end end end return primes end local function getdivisorparts(x, primes) local prime_num = #primes local tmp = {} local lim = mce(msq(x)) local primepos = 1 local dv = primes[primepos] while(primepos <= prime_num and dv <= lim) do if(x % dv == 0) then local asdf = {} asdf.p = dv asdf.cnt = 1 x = x / dv while(x % dv == 0) do x = x / dv asdf.cnt = asdf.cnt + 1 end tbli(tmp, asdf) lim = mce(msq(x)) end if(primepos == prime_num) then break end primepos = primepos + 1 dv = primes[primepos] end if(x ~= 1) then local asdf = {} asdf.p, asdf.cnt = x, 1 tbli(tmp, asdf) end return tmp end local function getdivisor(divisorparts, minlim) local t = {} local pat = 1 local len = #divisorparts local allpat = 1 for i = 1, len do allpat = allpat * (divisorparts[i].cnt + 1) end for t_i_pat = 0, allpat - 1 do local div = allpat local i_pat = t_i_pat local ret = 1 for i = 1, len do div = mfl(div / (divisorparts[i].cnt + 1)) local mul = mfl(i_pat / div) i_pat = i_pat % div for j = 1, mul do ret = ret * divisorparts[i].p end end if minlim == nil or minlim <= ret then tbli(t, ret) end end table.sort(t) return t end local retmin, retmax = n - 1, n - 1 local primes = getprimes(mce(msq(n))) local divisorparts = getdivisorparts(n, primes) local divisor = getdivisor(divisorparts) local dmax = mce(n^(1/3)) local numdivisorparts = #divisorparts local numdivisor = #divisor for i = 1, numdivisor do if(dmax < divisor[i]) then break end local divpart = getdivisorparts(divisor[i], primes) local k = 1 local numdivpart = #divpart for j = 1, numdivpart do while(k <= numdivisorparts) do if divpart[j].p == divisorparts[k].p then divisorparts[k].cnt = divisorparts[k].cnt - divpart[j].cnt k = k + 1 break else k = k + 1 end end if(numdivisorparts < k) then break end end local rem = mfl(n / divisor[i]) local remdiv = getdivisor(divisorparts, divisor[i]) local remlim = mce(msq(rem)) local numremdiv = #remdiv for j = 1, numremdiv do if(remlim < remdiv[j]) then break end local last = mfl(rem / remdiv[j]) retmin = mmi(retmin, divisor[i] + remdiv[j] + last - 3) end k = 1 for j = 1, numdivpart do while(k <= numdivisorparts) do if divpart[j].p == divisorparts[k].p then divisorparts[k].cnt = divisorparts[k].cnt + divpart[j].cnt k = k + 1 break else k = k + 1 end end if(numdivisorparts < k) then break end end end print(retmin .. " " .. retmax)