import java.lang.Math.sqrt

fun main(args : Array<String>) {
    var N = readLine()?.toLong() ?: return

    var min = N
    var end = sqrt(N.toDouble()).toInt()
    for (i in 1..end){
        var j = N / i
        if(i*j == N){
            var moveCount = i+j-2
            if(min > moveCount){
                min = moveCount
            }
        }
    }

    print("$min")
}