open System


[<EntryPoint>]
let main argv =
    let N = stdin.ReadLine()|>int64
    [for i in [1..(N|>double|>sqrt|>floor|>int)] do yield (if N%(i|>int64)<>0L then 10000000000000L else (N/(i|>int64))+(i|>int64)-(2L))]
    |>List.min
    |>stdout.WriteLine
    0