import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; FastReader in = new FastReader(inputStream); PrintWriter out = new PrintWriter(outputStream); No1664UnstableFn solver = new No1664UnstableFn(); solver.solve(1, in, out); out.close(); } static class No1664UnstableFn { public void solve(int testNumber, FastReader in, PrintWriter out) { long n = in.nextLong(); long ans = n; long tmp = toLong((Math.sqrt(n))); ans = Math.min(ans, tmp + 2 + (n - tmp * tmp)); for (long i = 2; i * i * i <= n; i++) { long k = toLong((Math.log(n) / Math.log(i))); if (Math.pow(i, k) > n) { out.println(i + " " + k); } ans = Math.min(ans, i + k + (n - toLong(Math.pow(i, k)))); } out.println(ans); } private long toLong(double sqrt) { long tmp = (long) sqrt; if (Math.abs(tmp + 1.0 - sqrt) < 0.00000001) return tmp + 1; return tmp; } } static class FastReader { BufferedReader br; StringTokenizer st = new StringTokenizer(""); public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } public FastReader(InputStream in) { br = new BufferedReader(new InputStreamReader(in)); } public String next() { while (st == null || (!st.hasMoreElements())) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } public long nextLong() { return Long.parseLong(next()); } } }