n=int(eval(input()))

x=int(n**0.5)+1

for i in range(x,0,-1):

    if n%i==0:

        print((-2+i+(n//i)))

        exit()

n=int(eval(input()))

x=int(n**0.5)

for i in range(x,0,-1):

    if n%i==0:

        print((-2+i+(n//i)))

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

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

-x = int(n**0.5) + 1 +x = int(n**0.5)