n = int(eval(input()))

l = []

for i in range(1,1000001):

    a = n / i

    if a.is_integer():

        l.append(i+n/i)

print((int(min(l)-2)))
n = int(eval(input()))

a = 10**20

for i in range(1,int(n**0.5)+1):

    if n%i==0:

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

print((a-2))
n = int(eval(input()))
l = []
for i in range(1, 1000001):
    a = n / i
    if a.is_integer():
        l.append(i + n / i)
print((int(min(l) - 2)))

n = int(eval(input()))
a = 10**20
for i in range(1, int(n**0.5) + 1):
    if n % i == 0:
        a = min(a, i + n // i)
print((a - 2))

-l = [] -for i in range(1, 1000001): -    a = n / i -    if a.is_integer(): -        l.append(i + n / i) -print((int(min(l) - 2))) +a = 10**20 +for i in range(1, int(n**0.5) + 1): +    if n % i == 0: +        a = min(a, i + n // i) +print((a - 2))