// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;



#define ll long long

#define mx 0

#define mn 1e9

#define v(dt) vector<dt>

#define pr(x, y) pair<x,y>

#define loop(x, s, n) for(int x = s; x < n; ++x)

#define in_arr(n) loop(i,0,n){cin>>a[i];}

#define out_arr(n) loop(i,0,n){cout<<a[i];}



const int N = 1e5 + 7;



inline void boost() {

    cin.tie(0), cout.tie(0), cin.sync_with_stdio(0), cout.sync_with_stdio(0);

}



//int a[N];



int main() {

    boost();

    ll n;

    cin>>n;

    ll res = 1e18;



    for (int i = 1;i<= sqrt(n); i++) {

        if (n % i == 0)

        {

            res = min(res,(i+(n/i))-2);

        }

    }

    cout<<res;



}

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

 * 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;

}