function Main(input) {
   
    var N = input[0].trim();

//	console.log("%s",N);

  	var result = N-1;
  	var a = Math.floor(Math.sqrt(N/2))+1;
    
    do{
      
      if(N % a == 0){
         b = N / a;
         result = result > (a+b-2) ? (a+b-2) : result 
//	     console.log("a:%s b:%s result:%s",a,b,result);

         break;
      }
      a--;

    }while(a> 0)

    console.log("%s",result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").split("\n"));