function Main(input) {
		input = input.split(" ");
		const num = parseInt(input[0], 10);
		if (num % 2 != 0 && num % 3 != 0 && num % 4 != 0 && num % 5 != 0 && num % 6 != 0 && num % 7 != 0 && num % 8 != 0 && num % 9 != 0) {
				console.log(num - 1);
				return;
		}
		var min = 0;
		var res = [0, 0];
		for (i = 1; i <= num/2; i++) {
				if (num % i == 0) {
						if (min == 0 || (i - 1) + (num / i - 1) < min) {
								res = [i, num / i];
								min = res[0] + res[1];
						}
				}
		}
		console.log(res[0] - 1 + res[1] - 1);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));