n=int(eval(input()))

n2=int(n**0.5)

for n3 in range(n2,0,-1):

    if n%n3==0:

        n4=n/n3

        n5=int((n3-1)+(n4-1))

        print(n5)

        break
n=int(eval(input()))



n2=int(n**0.5)

abmin=n

for i in range(1,n2+1):

    if n%i==0:

        ab=n//i+i-2

        abmin=min(ab,abmin)

        

print(abmin)
n = int(eval(input()))
n2 = int(n**0.5)
for n3 in range(n2, 0, -1):
    if n % n3 == 0:
        n4 = n / n3
        n5 = int((n3 - 1) + (n4 - 1))
        print(n5)
        break

n = int(eval(input()))
n2 = int(n**0.5)
abmin = n
for i in range(1, n2 + 1):
    if n % i == 0:
        ab = n // i + i - 2
        abmin = min(ab, abmin)
print(abmin)

-for n3 in range(n2, 0, -1): -    if n % n3 == 0: -        n4 = n / n3 -        n5 = int((n3 - 1) + (n4 - 1)) -        print(n5) -        break +abmin = n +for i in range(1, n2 + 1): +    if n % i == 0: +        ab = n // i + i - 2 +        abmin = min(ab, abmin) +print(abmin)