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

    for (x in Math.sqrt(n.toDouble()).toLong() downTo 1) {
        if (n % x == 0L) {
            val y = n / x
            val dist = x + y - 2
            println(dist)
            return
        }
    }
}