object Main extends App {
  import scala.io.StdIn._
  val n = readLong()
  var ans = 1000000000000L
  for(i <- 1L to(Math.sqrt(n).toLong)){
    if(n % i == 0){
      ans = Math.min(ans,i+n/i-2)
    }
  }
  println(ans)
}