import java.lang.Math

fun main(args: Array<String>) {
    val n = readLine()!!.toLong()
    // 2 <=n <=10**12 1000000000000


    var ans = n - 1
    val sqrt = Math.sqrt(n.toDouble())

    for (x in (1..(1 + sqrt.toInt())).reversed()) {
        if (n % x == 0L) {
            val y = n / x
            ans = Math.min(ans, (x - 1) + (y - 1))
        }
    }

    println(ans)
}

