import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val n     = sc.nextLong
  val sqrtN = Math.sqrt(n).toInt


  val res =
    (1 to sqrtN)
      .withFilter(n % _ == 0)
      .map{a => (a - 1) + (n / a - 1)}
      .min

  println(res)
}
