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 i = 1; i <= n; i++) { for (int j = 0; j <= n - i; j++) { for (int k = 0; k <= n - i - j; k++) { int pow = (int)Math.Pow(i, j) + k; if (pow == n) { if (output >= i + j + k) output = i + j + k; } } } } Console.WriteLine(output); } } }