fun main(args: Array<String>) {
    val N = readLine()!!.toLong()
    val n = Math.sqrt(N.toDouble()).toLong()
    var ans = Long.MAX_VALUE
    (1L..n).forEach { a ->
        if (N % a != 0L) return@forEach
        val b = N / a
        ans = Math.min(ans, a + b - 2)
    }
    println(ans)
}