N=int(eval(input()))

K=list()



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

  if(int(N/i)==N/i):

    M=int(N/i)  #N<=M

    L=i

    K.append(M+L-2)

    

print((min(K)))
import math

def make_divisors(n):

    divisors = []

    for i in range(2, int(math.sqrt(n))+1):

        if n % i == 0:

            divisors.append(i)



    divisors.sort()

    return divisors



def main():

    N=int(eval(input()))

    di=make_divisors(N)

    if di==[]:

        print((N-1))

    else:

        M=N//di[-1]

        print((di[-1]-1+M-1))



if __name__=="__main__":

    main()
N = int(eval(input()))
K = list()
for i in range(1, int(N**0.5) + 1):
    if int(N / i) == N / i:
        M = int(N / i)  # N<=M
        L = i
        K.append(M + L - 2)
print((min(K)))

import math


def make_divisors(n):
    divisors = []
    for i in range(2, int(math.sqrt(n)) + 1):
        if n % i == 0:
            divisors.append(i)
    divisors.sort()
    return divisors


def main():
    N = int(eval(input()))
    di = make_divisors(N)
    if di == []:
        print((N - 1))
    else:
        M = N // di[-1]
        print((di[-1] - 1 + M - 1))


if __name__ == "__main__":
    main()

-N = int(eval(input())) -K = list() -for i in range(1, int(N**0.5) + 1): -    if int(N / i) == N / i: -        M = int(N / i)  # N<=M -        L = i -        K.append(M + L - 2) -print((min(K))) +import math + + +def make_divisors(n): +    divisors = [] +    for i in range(2, int(math.sqrt(n)) + 1): +        if n % i == 0: +            divisors.append(i) +    divisors.sort() +    return divisors + + +def main(): +    N = int(eval(input())) +    di = make_divisors(N) +    if di == []: +        print((N - 1)) +    else: +        M = N // di[-1] +        print((di[-1] - 1 + M - 1)) + + +if __name__ == "__main__": +    main()