import java.lang.Math

fun main(args: Array<String>)
{
    val n = readLine()!!.toLong()

    var min = Long.MAX_VALUE
    for (i in 1..Math.floor(Math.sqrt(n.toDouble())).toInt()) {
        val r = n % i.toLong()

        if (r == 0L) {
            val can = i.toLong() + n / i.toLong() - 2L
            min = if (min > can) can else min
        }
    }

    println(min)
}
