import java.util.*

fun main(args : Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextDouble()
    val sqrt = Math.sqrt(n)

    val nLong = n.toLong()
    var current = sqrt.toLong()

    while (true) {
        if (nLong % current == 0L) {
            println(nLong / current + current - 2)
            break
        }
        current -= 1
    }

}