import std.algorithm, std.conv, std.range, std.stdio, std.string; void main() { auto n = readln.chomp.to!long; auto calcP(long n) { auto fn = factors(n).assumeSorted, nc = n.ncbrt; auto p1 = fn.lowerBound(nc); auto p2 = fn.equalRange(nc); auto p3 = fn.upperBound(nc); long[] r; if (!p1.empty) r ~= p1.back; if (!p2.empty) r ~= p2.front; if (!p3.empty) r ~= p3.front; return r; } auto calcQ(long n) { auto fn = factors(n).assumeSorted, nc = n.nsqrt; auto q1 = fn.lowerBound(nc); auto q2 = fn.equalRange(nc); auto q3 = fn.upperBound(nc); long[] r; if (!q1.empty) r ~= q1.back; if (!q2.empty) r ~= q2.front; if (!q3.empty) r ~= q3.front; return r; } auto r = long.max; foreach (p; calcP(n)) foreach (q; calcQ(n/p)) r = min(r, p + q + n/p/q - 3); writeln(r, " ", n-1); } auto factors(long n) { auto r = [1L, n]; foreach (i; 2..n.nsqrt+1) if (n % i == 0) r ~= [i, n/i]; r.sort(); return r; } pure T nsqrt(T)(T n) { import std.algorithm, std.conv, std.range, core.bitop; if (n <= 1) return n; T m = 1 << (n.bsr / 2 + 1); return iota(1, m).map!"a * a".assumeSorted!"a <= b".lowerBound(n).length.to!T; } pure T ncbrt(T)(T n) { import std.algorithm, std.conv, std.range, core.bitop; if (n <= 1) return n; T m = 1 << (n.bsr / 3 + 1); return iota(1, m).map!"a * a * a".assumeSorted!"a <= b".lowerBound(n).length.to!T; }