#include <bits/stdc++.h>
using namespace std;

#define int long long

int n;
int a,b;

signed main()
{
	cin>>n;
	for(a=sqrt(n);a>=1;a--)
		if(n%a==0)
		{
			b = n/a;
			break;
		}
	cout<<a+b-2<<endl;
}