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 = divisor(N)
    var min = Long.MAX_VALUE
    list.forEach {
        val a = N / it
        min = min(min, a + it)
    }
    print(min-2)
}

fun divisor(value : Long) : List<Long> {
    val max = Math.sqrt(value.toDouble()).toLong()
    return (1..max)
        .filter { value % it == 0L }
        .map { listOf(it, value / it) }
        .flatten()
        .sorted()
}