import numpy as np

N=int(eval(input()))

root=int(np.sqrt(N)//1)

a=N

b=N

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

    if N%i==0:

        a=i

        b=N//i

        break

print((a-1+b-1))
N=int(eval(input()))

root=int((N**0.5)//1)

a=N

b=N

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

    if N%i==0:

        a=i

        b=N//i

        break

print((a-1+b-1))

import numpy as np

N = int(eval(input()))
root = int(np.sqrt(N) // 1)
a = N
b = N
for i in range(root, 0, -1):
    if N % i == 0:
        a = i
        b = N // i
        break
print((a - 1 + b - 1))

N = int(eval(input()))
root = int((N**0.5) // 1)
a = N
b = N
for i in range(root, 0, -1):
    if N % i == 0:
        a = i
        b = N // i
        break
print((a - 1 + b - 1))

-import numpy as np - -root = int(np.sqrt(N) // 1) +root = int((N**0.5) // 1)