import math

import copy



n=int(eval(input()))



i=int(n**0.5)

j=0

# print(i)



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

    # print(i)

    if n==i:

        print((n-1))

        break

    if n%i==0:

        j=n/i

        print((int(i+j-2)))

        break

def main():

    n = int(eval(input()))

    ans = -1

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

        if n % i == 0:

            a = i

            b = n // i

            if ans == -1:

                ans = a + b - 2

            else:

                ans = min(ans,a + b - 2)

    print(ans)

if __name__ == '__main__':

    main()

import math
import copy

n = int(eval(input()))
i = int(n**0.5)
j = 0
# print(i)
for i in range(i + 1, 0, -1):
    # print(i)
    if n == i:
        print((n - 1))
        break
    if n % i == 0:
        j = n / i
        print((int(i + j - 2)))
        break

def main():
    n = int(eval(input()))
    ans = -1
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            a = i
            b = n // i
            if ans == -1:
                ans = a + b - 2
            else:
                ans = min(ans, a + b - 2)
    print(ans)


if __name__ == "__main__":
    main()

-import math -import copy +def main(): +    n = int(eval(input())) +    ans = -1 +    for i in range(1, int(n**0.5) + 1): +        if n % i == 0: +            a = i +            b = n // i +            if ans == -1: +                ans = a + b - 2 +            else: +                ans = min(ans, a + b - 2) +    print(ans) -n = int(eval(input())) -i = int(n**0.5) -j = 0 -# print(i) -for i in range(i + 1, 0, -1): -    # print(i) -    if n == i: -        print((n - 1)) -        break -    if n % i == 0: -        j = n / i -        print((int(i + j - 2))) -        break + +if __name__ == "__main__": +    main()