function Main(input) {
    var data = input.split("\n")
    var answer = Infinity;
	for(var i=1; i<=Math.sqrt(data[0]);i++){
		if(data[0]%i===0 ){
			var m = (data[0]/i-1) + (i-1);
			if( m < answer) {
				answer = m;
			}
		}
	}
	console.log(answer)
}
 
// Don't edit this line!
Main(require("fs").readFileSync("/dev/stdin", "utf8"));