n = int(eval(input()))

ans = n-1

cnt = 2

while cnt <= int(n**0.5)+1:

    if n%cnt==0:

        ans = min(ans, (cnt-1)+(n//cnt-1))

    cnt += 1

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

print((min(a+(n//a)-2 for a in range(1, int(n**0.5)+1) if n%a==0)))
n = int(eval(input()))
ans = n - 1
cnt = 2
while cnt <= int(n**0.5) + 1:
    if n % cnt == 0:
        ans = min(ans, (cnt - 1) + (n // cnt - 1))
    cnt += 1
print(ans)

n = int(eval(input()))
print((min(a + (n // a) - 2 for a in range(1, int(n**0.5) + 1) if n % a == 0)))

-ans = n - 1 -cnt = 2 -while cnt <= int(n**0.5) + 1: -    if n % cnt == 0: -        ans = min(ans, (cnt - 1) + (n // cnt - 1)) -    cnt += 1 -print(ans) +print((min(a + (n // a) - 2 for a in range(1, int(n**0.5) + 1) if n % a == 0)))