#include<algorithm>
#include<string>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<utility>
#include<functional>
#include<cassert>

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<vint> vvint;

int main(void) {
	ll n;
	cin >> n;
	ll ans = n;
	for (ll i = 1; i < sqrt(n);i++ ){
		if (n%i == 0) {
			ll a;
			a = n / i;
			if (a  + i - 2 < ans) {
				ans = a - 1 + i - 1;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

