// 解きかけ open System let n64 = stdin.ReadLine () |> int64 let n = n64 |> float let mutable ans = Int32.MaxValue let logn = log n for i in 2..int (10. ** 3.) do let index = logn / log (float i) |> int let a = (n64 - int64((float i) ** (float index)) |> int) + i + index if a < ans then ans <- a printfn "%d" ans