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