n = int(eval(input()))

a = n - 1

p = 1

for c in range(2, int((n ** 0.5) * 2)):

    if p % 2 == 1 and c > (n ** 0.5):

        break

    if n % c == 0:

        p = c

        w = int(n / c)

        if (w + c - 2) < a:

            a = (w + c -2)

        else:

            continue

    else:

        continue

print(a)

N = int(eval(input()))

ans = N - 1

p = 1

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

    if p % 2 == 1 and i > (N ** 0.5):

        break

    if N % i == 0:

        p = i

        j = N // i

        m = i + j - 2

        if m < ans:

            ans = m

        else:

            continue

    else:

        continue

print(ans)

n = int(eval(input()))
a = n - 1
p = 1
for c in range(2, int((n**0.5) * 2)):
    if p % 2 == 1 and c > (n**0.5):
        break
    if n % c == 0:
        p = c
        w = int(n / c)
        if (w + c - 2) < a:
            a = w + c - 2
        else:
            continue
    else:
        continue
print(a)

N = int(eval(input()))
ans = N - 1
p = 1
for i in range(2, int((N**0.5) + 1)):
    if p % 2 == 1 and i > (N**0.5):
        break
    if N % i == 0:
        p = i
        j = N // i
        m = i + j - 2
        if m < ans:
            ans = m
        else:
            continue
    else:
        continue
print(ans)

-n = int(eval(input())) -a = n - 1 +N = int(eval(input())) +ans = N - 1 -for c in range(2, int((n**0.5) * 2)): -    if p % 2 == 1 and c > (n**0.5): +for i in range(2, int((N**0.5) + 1)): +    if p % 2 == 1 and i > (N**0.5): -    if n % c == 0: -        p = c -        w = int(n / c) -        if (w + c - 2) < a: -            a = w + c - 2 +    if N % i == 0: +        p = i +        j = N // i +        m = i + j - 2 +        if m < ans: +            ans = m -print(a) +print(ans)