
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N = sc.nextLong()
    val upper = Math.sqrt(N)
    val candidates = for {
      i <- (1 to upper.toLong)
      if upper % i == 0
      j = (upper / i).toLong
    } yield i + j - 2
    
    val min = candidates.min
    println(min)
  }

}
