#include <iostream>
#include <iomanip>
#include <vector>
#include <string>

#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
using ll = long long;
#define rep(i,n) REP(i,0,n)
#define REP(i,x,n) for(int i=x;i<n;++i)

///////////////////////////////////////////////////
// -------------------- I/O -------------------- //
///////////////////////////////////////////////////
// https://stackoverflow.com/questions/610245/where-and-why-do-i-have-to-put-the-template-and-typename-keywords
template<typename T> void outputVec(const std::vector<T>& vec, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	for (typename std::vector<T>::const_iterator it = vec.begin(); it != vec.end() - 1; ++it) { std::cout << *it << " "; }
	std::cout << *(vec.end() - 1) << "\n";
}
template<typename T> void outputVal(const T& res, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	std::cout << res << "\n";
}
template<typename T> T inputVal() { T a; std::cin >> a; return a; }
template<typename T> std::vector<T> inputVec(T N) {
	std::vector<T> vec(N);
	for (typename std::vector<T>::iterator it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
	return vec;
}
template<typename T> void inputVec(std::vector<T>& vec) {
	for (typename std::vector<T>::iterator it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
}

///////////////////////////////////////////////////
// ------------------- utils ------------------- //
///////////////////////////////////////////////////
// change min/max
template<class T> inline bool chMin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chMax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

///////////////////////////////////////////////////
// ------------------- maths ------------------- //
///////////////////////////////////////////////////
// Greatest Common Divisor: https://en.wikipedia.org/wiki/Greatest_common_divisor
// Eucrid Algohrithm: a = qb + r 
template<typename T> T gcd(T a, T b) {
	if (a < b) std::swap(a, b);
	T r = a % b;
	while (r != 0) { a = b; b = r; r = a % b; }
	return b;
}
// Least Common Multiple: https://en.wikipedia.org/wiki/Least_common_multiple
template<typename T> T lcm(T a, T b) { return (a * b) / gcd(a, b); }

// prime factorisation
template<typename T> std::vector<T> primeFactorisation(T nb) {
	if (nb == 1) { return std::vector<T>(1, 1); }
	std::vector<T> ret;
	T i = 2;
	while (i*i <= nb) { if (nb % i == 0) { ret.push_back(i); nb /= i; } else { ++i; } }
	return ret;
}

// check if the aregument is a prime number
template<typename T> bool isPrime(const T N) {
	if (N < 2)      return false;
	if (N == 2)     return true;
	if (N % 2 == 0) return false; // remove even numbers
	T sqrtN = static_cast<T>(std::sqrt(N));
	for (int i = 3; i <= sqrtN; i += 2) { if (N % i == 0) return false; }
	return true;
}

///////////////////////////////////////////////////
// ------------------- main -------------------- //
///////////////////////////////////////////////////
void Main() {
	const ll N = inputVal<ll>();
	const ll sqN = static_cast<ll>(std::sqrt(N));

	ll i = sqN;
	for (; i > 0; --i) {
		if ((N % i) == 0) break;
	}

	const ll dist = i + (N / i) - 2;

	std::cout << dist << endl;
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout << std::fixed << std::setprecision(15);
	Main();

	return 0;
}


Measured memory_bytes: 256