function main(arg) {
    var num = parseInt(arg);
    //広さの上限を決める
    var jougen = Math.sqrt(num);
    var kyori = num;

    for(i=0;i<jougen;i++){
    	if((num%i===0)&&(num/i===Math.floor(num/i))){
    		if(i + num/i - 2 < kyori){
    			kyori = i + num/i - 2;
    		}
    	}
    }
    console.log(kyori);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));