const main = (N) => {
    var r = N
    const end = Math.ceil(Math.sqrt(N))
    for(var i =1;i<end;i++) {
        if(N % i == 0) {
            const k = Math.ceil(N/i)
            if(r > Math.abs(k-i)) {
                r = i+k
            }
        }
    }
    return r
}
const input = require('fs').readFileSync("/dev/stdin","utf8").split("\n")[0]
const N = Number(input)
console.log(main(N)-2)