N = int(eval(input()))

List_ans = []



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

    if N % i == 0:

        List_ans.append(i)

        

x = max(List_ans)

y = N//x



Ans = (x-1) + (y-1)

print(Ans)
import math



N = int(eval(input()))

root_N = int(math.sqrt(N)) + 1

A = 100000000000000000000000000000000000



for i in range(1, root_N):

    if N % i == 0:

        B = N//i

        A = min(A, B)



ans_1 = A

ans_2 = N//A

ans = ((ans_1)-1) + ((ans_2)-1)



print(ans)
N = int(eval(input()))
List_ans = []
for i in range(1, int(N ** (1 / 2)) + 1):
    if N % i == 0:
        List_ans.append(i)
x = max(List_ans)
y = N // x
Ans = (x - 1) + (y - 1)
print(Ans)

import math

N = int(eval(input()))
root_N = int(math.sqrt(N)) + 1
A = 100000000000000000000000000000000000
for i in range(1, root_N):
    if N % i == 0:
        B = N // i
        A = min(A, B)
ans_1 = A
ans_2 = N // A
ans = ((ans_1) - 1) + ((ans_2) - 1)
print(ans)

+import math + -List_ans = [] -for i in range(1, int(N ** (1 / 2)) + 1): +root_N = int(math.sqrt(N)) + 1 +A = 100000000000000000000000000000000000 +for i in range(1, root_N): -        List_ans.append(i) -x = max(List_ans) -y = N // x -Ans = (x - 1) + (y - 1) -print(Ans) +        B = N // i +        A = min(A, B) +ans_1 = A +ans_2 = N // A +ans = ((ans_1) - 1) + ((ans_2) - 1) +print(ans)