n = int(input()) if n == 1: print(1) exit() import math res = float('inf') for j in range(2, int(math.log2(n)+1)): i = int(n**(1/j)) k = n-pow(i, j) res = min(res, i+j+k) print(res)