n=int(eval(input()))

num=int(n**0.5)+1

mini=float('inf')

for k in range(1,num+1):

    i=k

    j=0

    if n%i==0:

        j=n//i



    if j!=0 and mini>=i+j-2:

        mini=i+j-2



print(mini)

n=int(eval(input()))



ans=10**12

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

    if n%i==0:

        ans=min(ans,i+n//i-2)

print(ans)
n = int(eval(input()))
num = int(n**0.5) + 1
mini = float("inf")
for k in range(1, num + 1):
    i = k
    j = 0
    if n % i == 0:
        j = n // i
    if j != 0 and mini >= i + j - 2:
        mini = i + j - 2
print(mini)

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

-num = int(n**0.5) + 1 -mini = float("inf") -for k in range(1, num + 1): -    i = k -    j = 0 +ans = 10**12 +for i in range(1, int(n**0.5) + 1): -        j = n // i -    if j != 0 and mini >= i + j - 2: -        mini = i + j - 2 -print(mini) +        ans = min(ans, i + n // i - 2) +print(ans)