def solve(string):

    n = int(string)

    l = int(n**0.5)

    while n % l > 0:

        l -= 1

    return str(l + n // l - 2)





if __name__ == '__main__':

    print((solve(eval(input()))))

def solve(string):

    n = int(string)

    for i in range(int(n**0.5) + 1, 0, -1):

        if n % i:

            continue

        else:

            return str(i + n // i - 2)





if __name__ == '__main__':

    print((solve(eval(input()))))

def solve(string):
    n = int(string)
    l = int(n**0.5)
    while n % l > 0:
        l -= 1
    return str(l + n // l - 2)


if __name__ == "__main__":
    print((solve(eval(input()))))

def solve(string):
    n = int(string)
    for i in range(int(n**0.5) + 1, 0, -1):
        if n % i:
            continue
        else:
            return str(i + n // i - 2)


if __name__ == "__main__":
    print((solve(eval(input()))))

-    l = int(n**0.5) -    while n % l > 0: -        l -= 1 -    return str(l + n // l - 2) +    for i in range(int(n**0.5) + 1, 0, -1): +        if n % i: +            continue +        else: +            return str(i + n // i - 2)