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