import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}

func main() {
    let n = readInt()
    var a = Int(sqrt(Double(n)))
    var b = a
    var ans = n - 1
    while ans > (a - 1) + (b - 1) {
        ans = (a - 1) + (b - 1)
        while n % a != 0 {
            a += 1
        }
        b = n / a
    }
    print((a - 1) + (b - 1))
}
main()

