import std.stdio, std.string, std.conv;

long solve(long n) {
    import std.algorithm;
    long result = long.max;
    for (long i = 1; i * i <= n; ++i) {
        if (n % i == 0) result = min(result, i+n/i-2);
    }
    return result;
}

void main() {
    long n = readln.chomp.to!long;
    solve(n).writeln;
}