n = int(eval(input()))

i = 1

ans = 10**13

while(i*i<=n):

    if n%i == 0:

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

    i+=1

print(ans)
n = int(eval(input()))



i = 1

ele = []

while i * i <= n:

    if n % i == 0:

        ele.append([i,n//i])

    i += 1



ans = 10**13

for i in range(len(ele)):

    ans = min(ans,ele[i][0]+ele[i][1]-2)

print(ans)
n = int(eval(input()))
i = 1
ans = 10**13
while i * i <= n:
    if n % i == 0:
        ans = min(ans, n // i + i - 2)
    i += 1
print(ans)

n = int(eval(input()))
i = 1
ele = []
while i * i <= n:
    if n % i == 0:
        ele.append([i, n // i])
    i += 1
ans = 10**13
for i in range(len(ele)):
    ans = min(ans, ele[i][0] + ele[i][1] - 2)
print(ans)

-ans = 10**13 +ele = [] -        ans = min(ans, n // i + i - 2) +        ele.append([i, n // i]) +ans = 10**13 +for i in range(len(ele)): +    ans = min(ans, ele[i][0] + ele[i][1] - 2)