def main(): n = int(input()) ans = n + 1 for j in range(1, 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()