import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

long calc(long n) {
    long ans = n - 1;
    for (long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            long x = n / i;
            ans = min(ans, (i - 1) + (x - 1));
        }
    }
    return ans;
}

void main() {
    long n = read!long;
    writeln(calc(n));
}
