object Main {
  def main(args:Array[String]) {
    val N = readLine().toLong
    var min = N
    for(i <- 1l to Math.sqrt(N).toLong) {
      if(N % i == 0 && (i + N / i - 2) < min) min = i + N / i - 2
    }
    println(min)
  }
}
