#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <cctype>
#define rep(i, l, r) for (int i = l; i <= r; ++i)
#define fo(i, l, r) for (int i = l; i < r; ++i)
#define dfo(i, x, y) for (int i = hd[x], y = e[i].to; i; i = e[i].nt, y = e[i].to)
#define w while
#define sf scanf
#define pf printf
#define br break
#define co continue
#define rt return
#define il inline
#define per(i, r, l) for (int i = r; i >= l; --i)
#define pfo(i, r, l) for (int i = r; i > l; --i)
#define ms(a, b) memset(a, b, sizeof(a))
#define mc(a, b) memcpy(a, b, sizeof(b))
#define lowbit(x) x & -x
#define N 100005
#define M 10010
#define ft first
#define sd second
#define mp make_pair
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef pair<int, int> pii;
const int mod = 1e9 + 7, inf = 0x3f3f3f3f;
const ld pai = 3.14159265358979323;
//#define DEBUG 1
struct IO {
#define MAXSIZE 1048576
    char buf[MAXSIZE], *p1, *p2;
    char pbuf[MAXSIZE], *pp;
#if DEBUG
#else
    IO() : p1(buf), p2(buf), pp(pbuf) {}
    ~IO() { fwrite(pbuf, 1, pp - pbuf, stdout); }
#endif
    inline char gc() {
#if DEBUG
        return getchar();
#endif
        if (p1 == p2)
            p2 = (p1 = buf) + fread(buf, 1, MAXSIZE, stdin);
        return p1 == p2 ? -1 : *p1++;
    }
    inline int blank(char ch) { return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t'; }
    il int ck(char ch) { return ch == '\n' || ch == '\r'; }
    template <class T>
    inline void read(T &x) {
        register double tmp = 1;
        register int sign = 0;
        x = 0;
        register char ch = gc();
        for (; !isdigit(ch); ch = gc())
            if (ch == '-')
                sign = 1;
        for (; isdigit(ch); ch = gc()) x = x * 10 + (ch ^ 48);
        if (ch == '.')
            for (ch = gc(); isdigit(ch); ch = gc()) tmp /= 10.0, x += tmp * (ch ^ 48);
        if (sign)
            x = -x;
    }
    inline void read(char *s) {
        register char ch = gc();
        for (; blank(ch); ch = gc())
            ;
        for (; !blank(ch); ch = gc()) *s++ = ch;
        *s = 0;
    }
    inline void gs(char *s) {
        register char ch = gc();
        for (; blank(ch); ch = gc())
            ;
        for (; !ck(ch); ch = gc()) *s++ = ch;
        *s = 0;
    }
    inline void read(char &c) {
        for (c = gc(); blank(c); c = gc())
            ;
    }
    inline void pc(const char &c) {
#if DEBUG
        putchar(c);
#else
        if (pp - pbuf == MAXSIZE)
            fwrite(pbuf, 1, MAXSIZE, stdout), pp = pbuf;
        *pp++ = c;
#endif
    }
    il void ps(const char *s) {
        int l = strlen(s);
        fo(i, 0, l) pc(s[i]);
        pc('\n');
    }
    template <class T>
    inline void write(T x) {
        if (x < 0)
            x = -x, pc('-');
        static T sta[35];
        T top = 0;
        do {
            sta[top++] = x % 10, x /= 10;
        } while (x);
        while (top) pc(sta[--top] + 48);
    }
    template <class T>
    inline void write(T x, char lastChar) {
        write(x), pc(lastChar);
    }
} io;



ll n, ans;



int main() {
	//freopen(".in", "r", stdin), freopen(".out", "w", stdout);
	io.read(n);
	ll i;
	for (i = sqrt(n); i; --i) {
		if (n % i == 0) br;
	}
	ans = i - 1 + n / i - 1;
	io.write(ans);
    rt 0;
}

Measured memory_bytes: 256