import scala.io.StdIn._
object Main extends App {
  def count(a: Long, b: Long): Long = a + b - 2

  val n = readLong
  var res = Long.MaxValue
  for (i <- 1 to math.sqrt(n).toInt if n % i == 0) {
    res = math.min(res, count(i, n / i))
  }

  println(res)
}
