import java.util.*
import java.io.PrintWriter

val pw = PrintWriter(System.out)
val MOD = 1000000007L
val INF = 2147483647
val LINF = 9223372036854775807L

fun main(args: Array<String>){
    solve()
    pw.flush()    
}

fun solve(){
    val n = nextLong()
    val max = Math.sqrt(n.toDouble()).toLong()
    var ans = LINF
    for (a in 1L..max) {
        if(n % a != 0L) continue
        val b = n / a
        val step = (a - 1) + (b - 1)
        ans = min(ans, step.toLong())
    }
    println(ans)
}


// Print
fun println(v: String){
    pw.println(v)
}
fun print(v: String){
    pw.print(v)
}

// Read
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = next().split(" ").map{ it.toInt() }
fun nextLongList() = next().split(" ").map{ it.toLong() }
fun nextDoubleList() = next().split(" ").map{ it.toDouble() }
fun nextAryln(n: Int) = Array(n){ next() }
fun nextIntAryln(n: Int) = IntArray(n){ nextInt() }
fun nextLongAryln(n: Int) = LongArray(n){ nextLong() }
fun nextDoubleAryln(n: Int) = DoubleArray(n) { nextDouble() }

// Math
fun max(a: Long = -LINF, b: Long = -LINF, c: Long = -LINF, d: Long = -LINF, e: Long = -LINF): Long = listOf(a, b, c, d, e).max()!!.toLong()
fun min(a: Long = LINF, b: Long = LINF, c: Long = LINF, d: Long = LINF, e: Long = LINF): Long = listOf(a, b, c, d, e).min()!!.toLong()
fun prime(from: Long, to: Long = from) : List<Long>{
    return (from..to).filter{ i ->
        val max = Math.sqrt(i.toDouble()).toLong()
        (2..max).all{ j -> i % j != 0L}
    }
}
fun gcd(a: Long, b: Long) : Long = if(a % b == 0L) b else gcd(b, (a % b))
fun lcm(a: Long, b: Long) : Long = a / gcd(a, b) * b
fun modpow(a: Long, n: Long, p:Long = MOD) : Long {
    var res = 1L
    var ar = a
    var nr = n
    while(nr > 0){
        if((nr and 1) == 1L) res = res * ar % p
        ar = ar * ar % p
        nr = nr shr 1
    }
    return res
}
fun modinv(a: Long, p: Long = MOD) : Long = modpow(a, p - 2, p)
fun ncr(n: Long, r: Long) : Long {
    var a = 1L
    var b = 1L
    for (i in 1..r) {
        a = a * (n + 1 - i) % MOD
        b = b * i % MOD
    }
    return modinv(b, MOD) * a % MOD
}

// Algorithm
fun dfs(nodes: Array<Node>, now: Int, seen: Array<Boolean>){
    seen[now] = true
    for (edge in nodes[now].edges) {
        if(seen[edge.to]) continue
        dfs(nodes, edge.to, seen)
    }
}
fun bfs(nodes: Array<Node>, start: Int) : Array<Long> {
    val queue = ArrayDeque<Int>()
    queue.add(start)
    val dist: Array<Long> = Array(nodes.size) { -1L }
    dist[start] = 0
    while(queue.isNotEmpty()){
        val now = queue.poll()
        for (edge in nodes[now].edges) {
            if(dist[edge.to] != -1L) continue
            dist[edge.to] = dist[now] + 1
            queue.add(edge.to)
        }
    }
    return dist
}
fun dijkstra(nodes: Array<Node>, start: Int) : Array<Long> {
    val queue = PriorityQueue<Edge>(16) { e1: Edge, e2: Edge ->
         if(e1.cost < e2.cost){
            return@PriorityQueue -1
         } else if (e2.cost > e1.cost) {
            return@PriorityQueue 1
         } else {
             return@PriorityQueue 0
         }
    }
    queue.add(Edge(start, start, 0))
    val dist: Array<Long> = Array(nodes.size) { LINF / 2 }
    dist[start] = 0
    while(queue.isNotEmpty()){
        val now = queue.poll()
        if(dist[now.to] < now.cost) continue;
        for (edge in nodes[now.to].edges) {
            if(dist[edge.to] <= dist[edge.from] + edge.cost) continue
            dist[edge.to] = dist[edge.from] + edge.cost
            queue.add(Edge(edge.from, edge.to, dist[edge.to]))
            nodes[edge.to].past = edge.from
        }
    }
    return dist
}


// Class
data class Node(val id: Int, var past: Int = -1, var edges: MutableList<Edge> = mutableListOf())
data class Edge(val from: Int, val to: Int, val cost: Long = 1L)
class UnionFind(size: Int){
    val par = IntArray(size) { i -> i }
    val size = IntArray(size) { 1 }
    fun root(x: Int) : Int {
        if(par[x] == x){
            return x
        } else {
            par[x] = root(par[x])
            return par[x]
        }
    }
    fun same(x: Int, y: Int) : Boolean = root(x) == root(y)
    fun unite(x: Int, y: Int){
        var a = root(x)
        var b = root(y)
        if(a == b) return
        if(size[a] < size[b]){
            var tmp = a
            a = b
            b = tmp
        }
        size[a] += size[b]
        par[b] = a
    }
    fun size(x: Int) : Int = size[root(x)]
}
class Permutation(val n: Int, var searched: Int = 0, var nextIndex: Int = 0){
    val size = fact(n)
    val permList = Array(size) { IntArray(n){ 0 } }

    fun fact(n: Int) : Int = if(n == 0) 1 else n * fact(n - 1)
    fun init(){
        create(0, IntArray(n) { 0 }, Array<Boolean>(n){ false })
    }
    fun create(num: Int, list: IntArray, flag: Array<Boolean>){
        if(num == n){
            permList[searched] = list.copyOf()
            searched++
        }
        for (i in 0 until n) {
            if(flag[i]) continue
            list[num] = i
            flag[i] = true
            create(num + 1, list, flag)
            flag[i] = false
        }
    }
    fun hasNext() : Boolean {
        if(nextIndex < size){
            return true
        } else {
            nextIndex = 0
            return false
        }
    }
    fun nextPerm() : IntArray = permList[nextIndex++]
}
class Combination(val max: Int){
    val fac = LongArray(max)
    val finv = LongArray(max)
    val inv = LongArray(max)
    val p = MOD.toInt()
    fun init(){
        fac[0] = 1
        fac[1] = 1
        finv[0] = 1
        finv[1] = 1
        inv[1] = 1
        for (i in 2 until max) {
            fac[i] = fac[i - 1] * i % p
            inv[i] = p - inv[p % i] * (p / i) % p;
            finv[i] = finv[i - 1] * inv[i] % p
        }
    }
    fun com(n: Int, r: Int) : Long = if(n < r || (n < 0 || r < 0)) 0 else fac[n] * (finv[r] * finv[n - r] % p) % p
}

Measured memory_bytes: 36188