n=int(eval(input()))

ans=10**13

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

    j=n//i

    if n%i==0:

        ans=min(ans,i+j)

print((ans-2))

n=int(eval(input()))

ans=10**18

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

    if n%i!=0:continue

    j=n//i

    t=i+j-2

    ans=min(t,ans)

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

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

-ans = 10**13 +ans = 10**18 +    if n % i != 0: +        continue -    if n % i == 0: -        ans = min(ans, i + j) -print((ans - 2)) +    t = i + j - 2 +    ans = min(t, ans) +print(ans)