n = int(eval(input()))

import math

m = int(math.sqrt(n))+1

anss = []

for x in range(1, m+1):

  y = n//x

  z = n%x

  if z == 0:

    anss.append(abs(x-1)+abs(y-1))

print((min(anss)))

n = int(eval(input()))

def make_divisors(n):

    divisors = []

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

        if n % i == 0:

            divisors.append(i)

            if i != n // i:

                divisors.append(n//i)



    #divisors.sort(reverse=True)

    return divisors



l = make_divisors(n)

min_ = float('inf')

for i in range(len(l)):

    min_ = min(min_, l[i]-1+n//l[i]-1)

print(min_)

n = int(eval(input()))
import math

m = int(math.sqrt(n)) + 1
anss = []
for x in range(1, m + 1):
    y = n // x
    z = n % x
    if z == 0:
        anss.append(abs(x - 1) + abs(y - 1))
print((min(anss)))

n = int(eval(input()))


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    # divisors.sort(reverse=True)
    return divisors


l = make_divisors(n)
min_ = float("inf")
for i in range(len(l)):
    min_ = min(min_, l[i] - 1 + n // l[i] - 1)
print(min_)

-import math -m = int(math.sqrt(n)) + 1 -anss = [] -for x in range(1, m + 1): -    y = n // x -    z = n % x -    if z == 0: -        anss.append(abs(x - 1) + abs(y - 1)) -print((min(anss))) + +def make_divisors(n): +    divisors = [] +    for i in range(1, int(n**0.5) + 1): +        if n % i == 0: +            divisors.append(i) +            if i != n // i: +                divisors.append(n // i) +    # divisors.sort(reverse=True) +    return divisors + + +l = make_divisors(n) +min_ = float("inf") +for i in range(len(l)): +    min_ = min(min_, l[i] - 1 + n // l[i] - 1) +print(min_)