using static System.Math; using System; public class Hello { static void Main() { var n = long.Parse(Console.ReadLine().Trim()); if (n <= 2) Console.WriteLine(n); else getAns(n); } static void getAns(long n) { var ans = n + 1; var imax = (int)(Log10(n) / Log10(2)); for (int j = 2; j <= imax; j++) { var i = (int)Pow(n, 1d / j); var x = 1L; for (int a = 0; a < j; a++) x *= i; var k = n - x; ans = Min(ans, i + j + k); } Console.WriteLine(ans); } }