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