n = int(input()) res = n for i in range(1, 1000000): for j in range(0, 100): if i ** j > n: break print(i, j) res = min(res, i + j + n - i ** j) k = int(n ** 0.5) res = min(res, k + n - k**2 + 2) print(res)