function Main(input) {
		input = input.split(" ");
		const num = parseInt(input[0], 10);
		var min = 0;
		var res = 0;
		for (i = 1; i <= Math.sqrt(num); i++) {
				if (num % i == 0) {
						if (min == 0 || (i - 1) + (num / i - 1) < min) {
								res = i + (num / i) - 2;
								min = res;
						}
				}
		}
		console.log(res);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));