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