n = int(input()) ans = 1 + 0 + (n - 1) j = 10 ** 18 i = 2 while j != 1 and i <= n: j = 1 x = i while x * i <= n: x *= i j += 1 k = n - x ans = min(ans, i + j + k) i += 1 print(ans)