function main(input){
  var smallFactor = 1;
  var bigFactor = 1;
  for(var i = 1;i <= Math.sqrt(input);i++){
    if(input % i === 0){
      smallFactor = i;
      bigFactor = input / i;
    }
  }
  console.log(smallFactor + bigFactor -2);
}

main(Number(require("fs").readFileSync("/dev/stdin","utf8")));