fun main(args: Array<String>) {
    abc144c()
}

fun abc144c() {
    val n = readLine()!!.toLong()

    val answer = (1..Math.pow(n.toDouble(), 1 / 2.toDouble()).toLong()).map { i1 ->
        val i2 = n / i1
        if (i1 * i2 == n) i1 - 1 + i2 - 1 else Long.MAX_VALUE
    }.min()

    println(answer)
}
