
import java.lang.Long.min
import java.lang.Math.sqrt

fun main (args:Array<String>){
    val N = readLine()!!.toLong()
    var minResult = (N - 1)
    val sqrtN = sqrt(N.toDouble()).toInt()
    for (i in 1..sqrtN) {
        if (N % i == 0L) {
            val j = N / i
            minResult = min(minResult, ((i - 1) + (j - 1)))
        }
    }
    println(minResult)
}
