def check(i,j): return N >= i ** j N = int(input()) ans = 10 ** 18 for j in range(60): lb = 0 ub = 10 ** 18 while ub - lb > 1: mid = (ub + lb) // 2 if check(mid,j): lb = mid else: ub = mid k = N - lb ** j ans = min(ans, j + lb + k) print(ans)