import java.math.*

fun main(args: Array<String>) {
    val N = readInputLine().toLong()
    
    var ans = Long.MAX_VALUE
    
    for (i in LongRange(1L, Math.sqrt(N.toDouble()).toLong() + 1L)) {
        if (N % i == 0L) {
            ans = Math.min(ans, i - 1L + (N / i) - 1L)
        }
    }
    
    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}
