fun main(args: Array<String>) {
    val N = nextLong()
    var a = Math.sqrt(N.toDouble()).toLong()
    while (N % a != 0L && a > 1) a -= 1
    val b = N / a
    println(a + b - 2)
}fun next() = readLine()!!
fun nextLong() = next().toLong()
