using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Numerics; namespace yukicoder { class Program { const int intMax = 1000000000; const long longMax = 2000000000000000000; static void Main(string[] args) { long n = long.Parse(Console.ReadLine()); long ans = longMax; if(n < 4) Console.WriteLine(n); for(long j = 2; j <= Math.Log2(n); j++) { long i = (long)Math.Pow(n, 1 / j); while(Math.Pow(i + 1, j) <= n) i++; long k = n - (long)Math.Pow(i, j); ans = Math.Min(ans, i + j + k); } Console.WriteLine(ans); } } }