n = int(eval(input()))

ans = n

for i in range(1,int(n**.5)+2):

  if n%i == 0:

    ans = min(ans, i + n//i - 2)

print(ans)
def divisor(n):

    ass = []

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

        if n%i == 0:

            ass.append(i)

            ass.append(n//i)

    return sorted(ass)



n = int(eval(input()))

p = divisor(n)

ans = n + 10

for x in p:

  if x*x > n:

    break

  y = n//x

  if ans > y+x:

    ans = y+x

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

def divisor(n):
    ass = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            ass.append(i)
            ass.append(n // i)
    return sorted(ass)


n = int(eval(input()))
p = divisor(n)
ans = n + 10
for x in p:
    if x * x > n:
        break
    y = n // x
    if ans > y + x:
        ans = y + x
print((ans - 2))

+def divisor(n): +    ass = [] +    for i in range(1, int(n**0.5) + 1): +        if n % i == 0: +            ass.append(i) +            ass.append(n // i) +    return sorted(ass) + + -ans = n -for i in range(1, int(n**0.5) + 2): -    if n % i == 0: -        ans = min(ans, i + n // i - 2) -print(ans) +p = divisor(n) +ans = n + 10 +for x in p: +    if x * x > n: +        break +    y = n // x +    if ans > y + x: +        ans = y + x +print((ans - 2))