using System; using System.Collections.Generic; using System.Text; namespace yukicoder_contest_312 { class _2_2 { static void Main (string[] args) { long n = long.Parse(Console.ReadLine()); long output = n; for (int k = 1; k <= n; k++) { for (int j = 0; j <= n - k; j++) { for (int i = 0; i <= n - k - j; i++) { int pow = (int)Math.Pow(i, j) + k; if (pow == n) { if (output >= i + j + k) output = i + j + k; } } } } Console.WriteLine(output); } } }