def main(): n = int(input()) ans = float("inf") for j in range(100): ok = 1 ng = int(1e19) while ng - ok > 1: mid = (ok + ng) // 2 if pow(mid, j) <= n: ok = mid else: ng = mid if n >= pow(ok, j): ans = min(ans, ok + j + (n - pow(ok, j))) print(ans) main()