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

