import math



n = int(eval(input()))

b = 0

list = []

sqrt = math.ceil(math.sqrt(n))

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

	if(n%i==0):

		b = i

print((b + (n//b) -2))
N = int(eval(input()))

ans=1e+18

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

    if(N%i==0):

        ans = min(ans,int(i+N/i-2))

print(ans)
import math

n = int(eval(input()))
b = 0
list = []
sqrt = math.ceil(math.sqrt(n))
for i in range(1, sqrt + 1):
    if n % i == 0:
        b = i
print((b + (n // b) - 2))

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

-import math - -n = int(eval(input())) -b = 0 -list = [] -sqrt = math.ceil(math.sqrt(n)) -for i in range(1, sqrt + 1): -    if n % i == 0: -        b = i -print((b + (n // b) - 2)) +N = int(eval(input())) +ans = 1e18 +for i in range(1, int(N**0.5 + 1)): +    if N % i == 0: +        ans = min(ans, int(i + N / i - 2)) +print(ans)