n=int(eval(input()))

a=-1

b=-1

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

  #print(i,n/i)

  if n/i-int(n/i)==0:

    a=i

    b=int(n/i)

    

    

print((a+b-2))
n=int(eval(input()))

#n=a*bのa+b-2のmin

ans=float("inf")

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

  if n%i==0:

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

print(ans)
n = int(eval(input()))
a = -1
b = -1
for i in range(1, int(n**0.5) + 1):
    # print(i,n/i)
    if n / i - int(n / i) == 0:
        a = i
        b = int(n / i)
print((a + b - 2))

n = int(eval(input()))
# n=a*bのa+b-2のmin
ans = float("inf")
for i in range(1, int(n**0.5) + 1):
    if n % i == 0:
        ans = min(ans, n // i + i - 2)
print(ans)

-a = -1 -b = -1 +# n=a*bのa+b-2のmin +ans = float("inf") -    # print(i,n/i) -    if n / i - int(n / i) == 0: -        a = i -        b = int(n / i) -print((a + b - 2)) +    if n % i == 0: +        ans = min(ans, n // i + i - 2) +print(ans)