import std.algorithm, std.conv, std.range, std.stdio, std.string; void main() { auto n = readln.chomp.to!long; auto calcP(long n) { foreach_reverse (p; 1..ncbrt(n)*2) if (n % p == 0) return p; assert(0); } auto calcQ(long n) { foreach_reverse (q; 1..nsqrt(n)*2) if (n % q == 0) return q; assert(0); } auto p = calcP(n); auto q = calcQ(n/p); auto r = n/p/q; writeln(p + q + r - 3, " ", n - 1); } 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; }