import java.util.Scanner
import java.io.PrintWriter

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val pw = new PrintWriter(System.out)

    val n: Long = sc.nextLong()
    for (i <- math.sqrt(n).toInt to 1 by -1) {
      if (n % i == 0) {
        pw.println(i - 1 + n / i - 1)
        pw.flush()
        return
      }
    }

    pw.flush()
  }
}