#include using namespace std; int main() { int V; cin >> V; vector divs; for (int i = 1; i <= V; ++i) if (V % i == 0) divs.push_back(i); int ans = 4 * V + 2; for (int d1 : divs) for (int d2 : divs) if ((V / d1) % d2 == 0) { int d3 = V / d1 / d2; ans = min(ans, 2 * (d1*d2 + d1*d3 + d2*d3)); } cout << ans << endl; return 0; }