import java.util.*

fun <T : Comparable<T>> min(i: T, j:T):T {
    return if (i < j) i else j
}
fun main(args: Array<String>) {
    val (N) = readLine()!!.split(" ").map { it.toLong() }
    val list = makeDivisors(N)
    var min = Long.MAX_VALUE
    list.forEach {
        val a = N / it
        min = min(min, a + it)
    }
    print(min-2)
}

fun makeDivisors(n:Long): LongArray {
    val list = mutableListOf<Long>()
    for (i in 1 .. Math.pow(n.toDouble(), 0.5).toInt() + 1) {
        if (n % i == 0L) {
            list.add(i.toLong())
            if (i.toLong() != (n / i)) {
                list.add(n / i)
            }
        }
    }
    return list.toLongArray()
}