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); return; } long mpow(long x, long y) { long ret = 1; while (y > 0) { if((y & 1) == 1) ret *= x; x *= x; y >>= 1; } return ret; } for(long j = 2; j <= Math.Log2(n); j++) { long i = (long)Math.Pow(n, 1.0 / j); while(Math.Pow(i + 1, j) <= n) i++; long k = n - mpow(i, j); ans = Math.Min(ans, i + j + k); } Console.WriteLine(ans); } } }