fun main(args:Array<String>) {
    val n = readLine()!!.toLong()

    var ans = n
    for(i in (1..n)) {
        if(i*i > n) {
            break
        }
        if(n % i == 0L) {
            val tmp = (i-1) + (n/i-1)
            ans = Math.min(ans, tmp)
        }
    }
    println(ans)
}
