let () =
  let n = Scanf.sscanf (input_line stdin) "%d" (fun a -> a) in
  let rec loop i =
    if i * i > n then []
    else if n mod i == 0 then
      (i, n / i) :: loop (i + 1)
    else
      loop (i + 1)
  in 
  let ans = List.fold_left (fun c (a, b) -> min c (a + b - 2)) 100000000000000 (loop 1)
  in
  print_int ans;
  print_newline ()
