N=int(eval(input()))

L=float("inf")

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

    if N%i==0:

        x,y=i,N//i

        l=x+y-2

        L=min(L,l)

print(L)
N=int(eval(input()))

ans=min(i-1+N//i-1 for i in range(1,int(N**0.5)+1) if N%i==0)

print(ans)
N = int(eval(input()))
L = float("inf")
for i in range(1, int(N**0.5) + 1):
    if N % i == 0:
        x, y = i, N // i
        l = x + y - 2
        L = min(L, l)
print(L)

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

-L = float("inf") -for i in range(1, int(N**0.5) + 1): -    if N % i == 0: -        x, y = i, N // i -        l = x + y - 2 -        L = min(L, l) -print(L) +ans = min(i - 1 + N // i - 1 for i in range(1, int(N**0.5) + 1) if N % i == 0) +print(ans)