function Main (input){
  input = input.split("\n");
  tmp = input[0].split(" ");
  var N = parseInt(tmp[0],10);
  var i = Math.sqrt(N);
  while(N%i != 0){
    i -= 1;
  }
  j = N/i;
  susumi = i+j-2;
  console.log(susumi);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));