n = int(eval(input()))

def divisor(n): 

    i = 1

    a = 0

    b = 0

    out = float('inf')

    while i * i <= n:

        if n%i == 0:

            a = i

            b = n//i

        if a+b < out:

          out = a+b

        i += 1

    return out

print((divisor(n)-2))
n = int(eval(input()))

def divisor(n): 

    i = 1

    out = float('inf')

    while i * i <= n:

        if n%i == 0:

          out = min((i+n//i),out)

        i += 1

    return out

print((divisor(n)-2))
n = int(eval(input()))


def divisor(n):
    i = 1
    a = 0
    b = 0
    out = float("inf")
    while i * i <= n:
        if n % i == 0:
            a = i
            b = n // i
        if a + b < out:
            out = a + b
        i += 1
    return out


print((divisor(n) - 2))

n = int(eval(input()))


def divisor(n):
    i = 1
    out = float("inf")
    while i * i <= n:
        if n % i == 0:
            out = min((i + n // i), out)
        i += 1
    return out


print((divisor(n) - 2))

-    a = 0 -    b = 0 -            a = i -            b = n // i -        if a + b < out: -            out = a + b +            out = min((i + n // i), out)