import java.util.*

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

    val n = scanner.nextLong()

    var ret = n
    (1L..1000000L).forEach { i ->
        if (n % i != 0L) return@forEach
        ret = Math.min(ret, i + n / i - 2)
    }

    println(ret)
}