import math

A = int(eval(input()))

B = int(math.sqrt(A))

count = 0

for i in reversed(list(range(1,B+1))):

	if count == 0:

		if A % i == 0:

			print((int(i+A/i-2)))

			count += 1
import math



N=int(eval(input()))

P=math.sqrt(N)

C=float("inf")

for i in range (1,int(P+1)):

	if N%i==0:

		C=min(C,(i+N//i))

print((C-2))
import math

A = int(eval(input()))
B = int(math.sqrt(A))
count = 0
for i in reversed(list(range(1, B + 1))):
    if count == 0:
        if A % i == 0:
            print((int(i + A / i - 2)))
            count += 1

import math

N = int(eval(input()))
P = math.sqrt(N)
C = float("inf")
for i in range(1, int(P + 1)):
    if N % i == 0:
        C = min(C, (i + N // i))
print((C - 2))

-A = int(eval(input())) -B = int(math.sqrt(A)) -count = 0 -for i in reversed(list(range(1, B + 1))): -    if count == 0: -        if A % i == 0: -            print((int(i + A / i - 2))) -            count += 1 +N = int(eval(input())) +P = math.sqrt(N) +C = float("inf") +for i in range(1, int(P + 1)): +    if N % i == 0: +        C = min(C, (i + N // i)) +print((C - 2))