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

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

    for (i in Math.pow(n.toDouble(), 0.5).toLong() downTo 1) {
        if (n % i == 0L) return println(i + n / i - 2)
    }
}
