let rec max_divisor acc i n =
  if n < i * i then acc
  else max_divisor (if n mod i = 0 then i else acc) (i + 1) n

let () = Scanf.scanf "%d" @@ fun n ->
  let i = max_divisor 1 1 n in
  Printf.printf "%d\n" @@ i + n / i - 2

