n=int(eval(input()))

for i in range(int(n**.5),0,-1):

  if n%i<1: print((i+n//i-2)); break
n=int(eval(input()))

print((min(i+n//i-2 for i in range(1,int(n**.5)+1) if n%i<1)))
n = int(eval(input()))
for i in range(int(n**0.5), 0, -1):
    if n % i < 1:
        print((i + n // i - 2))
        break

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

-for i in range(int(n**0.5), 0, -1): -    if n % i < 1: -        print((i + n // i - 2)) -        break +print((min(i + n // i - 2 for i in range(1, int(n**0.5) + 1) if n % i < 1)))