import java.util.*

fun main(args: Array<String>) {
    val sc = java.util.Scanner(System.`in`)
    val n = sc.nextLong()

    var x = 1L
    var r = Long.MAX_VALUE
    while (true) {
        if (x == 1L) {
            r = n - 1
        } else if (n % x == 0L) {
            r = Math.min (r, n / x - 1 + x - 1)
        }
        x++
        if (x * x > n) {
            break
        }
    }
    println(r)
}
