n = int(input()) import math ans = 10 ** 19 if n == 1: print(1) exit() for j in range(1,10000): i = math.floor(n ** (1/j)) ans = min(ans, i + j + n - i ** j) print(ans)