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