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