import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); long n = sc.nextLong(); sc.close(); long ans = n + 1; for (int j = 1; j < 60; j++) { int i = root(n, j); long k = n - power(i, j); ans = Math.min(ans, i + j + k); } System.out.println(ans); } static int root(long x, int n) { int ng = 1000000001; int ok = 1; while (ng - ok > 1) { int mid = (ok + ng) / 2; if (Math.pow(mid, n) <= Long.MAX_VALUE) { ok = mid; } else { ng = mid; } } ng = ok + 1; ok = 1; while (ng - ok > 1) { int mid = (ok + ng) / 2; if (power(mid, n) <= x) { ok = mid; } else { ng = mid; } } return ok; } static long power(long x, long n) { if (n == 0) { return 1; } long val = power(x, n / 2); val = val * val; if (n % 2 == 1) { val = val * x; } return val; } }