import math 



N=int(eval(input()))



li=[]

l=0

m=0



for i in range(math.floor(math.sqrt(N))):

  if N%(i+1)==0:

    l=i

    m=N/(i+1)-1

    li.append(l+m)

  else:

    pass



print((int(min(li))))



N=int(eval(input()))



answer=0



for i in range(int(pow(N,1/2)),0,-1):

    if N%i==0:

        answer=(i-1)+(N//i-1)

        break

print(answer)

import math

N = int(eval(input()))
li = []
l = 0
m = 0
for i in range(math.floor(math.sqrt(N))):
    if N % (i + 1) == 0:
        l = i
        m = N / (i + 1) - 1
        li.append(l + m)
    else:
        pass
print((int(min(li))))

N = int(eval(input()))
answer = 0
for i in range(int(pow(N, 1 / 2)), 0, -1):
    if N % i == 0:
        answer = (i - 1) + (N // i - 1)
        break
print(answer)

-import math - -li = [] -l = 0 -m = 0 -for i in range(math.floor(math.sqrt(N))): -    if N % (i + 1) == 0: -        l = i -        m = N / (i + 1) - 1 -        li.append(l + m) -    else: -        pass -print((int(min(li)))) +answer = 0 +for i in range(int(pow(N, 1 / 2)), 0, -1): +    if N % i == 0: +        answer = (i - 1) + (N // i - 1) +        break +print(answer)