N = int(input()) # jは最大でも60 ans = N for j in range(1, 60): i = N ** (1/j) floor, ceil = int(i), int(i)+1 k = N-floor**j ans = min(ans, floor+j+k) k = N-(floor-1)**j ans = min(ans, floor+j+k-1) print(ans)