#include<cstdio>

long n;

int main() {
    scanf("%ld", &n);
    long a = 0;
    for (long i = 1; i * i <= n; i++) {
        if (n % i == 0) a = i;
    }
    printf("%ld\n", a + n / a - 2);
    return 0;
}
