import math

input_num = int(eval(input()))

num_sqrt = int(math.sqrt(input_num))



minimam = input_num

for i in range(num_sqrt+1,0,-1):

    q, mod = divmod(input_num, i)

    distance = q + i -2

    if mod == 0 and minimam > distance:

        minimam = distance

print(minimam)
import math

def main1():

    input_num = int(eval(input()))

    num_sqrt = int(math.sqrt(input_num))



    minimam = input_num

    for i in range(num_sqrt+1,0,-1):

        q, mod = divmod(input_num, i)

        if mod == 0:

            distance = q + i -2

            if minimam > distance:

                minimam = distance

    print(minimam)

main1()
import math

input_num = int(eval(input()))
num_sqrt = int(math.sqrt(input_num))
minimam = input_num
for i in range(num_sqrt + 1, 0, -1):
    q, mod = divmod(input_num, i)
    distance = q + i - 2
    if mod == 0 and minimam > distance:
        minimam = distance
print(minimam)

import math


def main1():
    input_num = int(eval(input()))
    num_sqrt = int(math.sqrt(input_num))
    minimam = input_num
    for i in range(num_sqrt + 1, 0, -1):
        q, mod = divmod(input_num, i)
        if mod == 0:
            distance = q + i - 2
            if minimam > distance:
                minimam = distance
    print(minimam)


main1()

-input_num = int(eval(input())) -num_sqrt = int(math.sqrt(input_num)) -minimam = input_num -for i in range(num_sqrt + 1, 0, -1): -    q, mod = divmod(input_num, i) -    distance = q + i - 2 -    if mod == 0 and minimam > distance: -        minimam = distance -print(minimam) + +def main1(): +    input_num = int(eval(input())) +    num_sqrt = int(math.sqrt(input_num)) +    minimam = input_num +    for i in range(num_sqrt + 1, 0, -1): +        q, mod = divmod(input_num, i) +        if mod == 0: +            distance = q + i - 2 +            if minimam > distance: +                minimam = distance +    print(minimam) + + +main1()