// Slower C++ solution:
#include<iostream>

#include<math.h>

using namespace std;

int main()

{

     long long int n;

     long long int i,j,k,t;

     cin>>n;

     t=ceil(sqrt(n));

    



    for( i=t;i>0;i--)

    {

         if(n%i==0)

         {

            j=i;



            k=n/i;



            cout<<j+k-2<<endl;

            break;

         }

    }





     return 0;





}


// Faster C++ solution for the same problem (measured speedup: 4.181070858109474x):
/**

 * Created By: Anonyman637

 * Created On: 3/6/2020 6:27:28 AM

 */



/* =============================================================================

   ================================== HEADERS ==================================

   ========================================================================== */



#include <cstdio>

#include <string>

#include <cmath>



/* =============================================================================

   ================================= TYPEDEFS ==================================

   ========================================================================== */



typedef char i8;

typedef short i16;

typedef int i32;

typedef long long i64;



typedef unsigned char ui8;

typedef unsigned short ui16;

typedef unsigned int ui32;

typedef unsigned long long ui64;



using namespace std;



/* =============================================================================

   ================================== MACROS ===================================

   ========================================================================== */



#ifdef DEBUG

#define debug(format, ...) printf(format, __VA_ARGS__)

#else

#define debug(format, ...) 

#endif



#ifdef FILEIO

#define INFILE "fileio\\"__FILE__"In.txt"

#define OUTFILE "fileio\\"__FILE__"Out.txt"

#endif



/* =============================================================================

   ================================== GLOBALS ==================================

   ========================================================================== */





/* =============================================================================

   =================================== SETUP ===================================

   ========================================================================== */



i32 setup() {



#ifdef FILEIO

        if(freopen(INFILE, "r", stdin) == NULL) return 401;

        if(freopen(OUTFILE, "w", stdout) == NULL) return 402;

#endif



        return 0;

}





/* =============================================================================

   ================================= FUNCTIONS =================================

   ========================================================================== */



i32 main() {



        i32 errorInSetup = setup();

        if (errorInSetup) exit(errorInSetup);



        i64 i, t;

        i64 n, sqrtN, steps;

        scanf("%lld", &n);

        sqrtN = ceil(sqrt((double) n));

        for (i = sqrtN; i > 0; i--) {

                if (n % i == 0) {

                        steps = (n / i) + i - 2;

                        break;

                }

        }



        printf("%lld", steps);

        

        return 0;

}