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()))

ans = N - 1

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

    if N % i == 0:

        j = N // i

        m = i + j - 2

        ans = min(ans, m)

print(ans)

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()))
ans = N - 1
for i in range(2, int((N**0.5) + 1)):
    if N % i == 0:
        j = N // i
        m = i + j - 2
        ans = min(ans, m)
print(ans)

-p = 1 -    if p % 2 == 1 and i > (N**0.5): -        break -        p = i -        if m < ans: -            ans = m -        else: -            continue -    else: -        continue +        ans = min(ans, m)