let getQQList (n: int64) =
    seq {for a in 2L..n do
         for b in 2L..n do
         if a * b = n then yield a - 1L + b - 1L}

let n = stdin.ReadLine() |> int64
let ans = getQQList n |> Seq.sort |> Seq.head

printfn "%d" ans