function Main(input){
    input = parseInt(input);
    var i = input;
    i = Math.floor(i/2)+1;
    var array = [];
    while(i--){
        if(input%i === 0){
            array.push((input/i)+i);
        }
    }
    console.log(array.reduce((a,b)=>Math.min(a,b))-2);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8")); 