N = int(eval(input()))



tmp = 0

for i in range(int(N ** (0.5)), 0, -1):

    if N % i == 0:

        tmp = i + (N // i)

        break



print((tmp - 2))
N = int(eval(input()))



ans = 0

for n in range(int(N ** 0.5), 0, -1):

    if N % n == 0:

        ans = n + (N // n) - 2

        break



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

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

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