def main():

    N = int(eval(input()))

    loop = int(N ** 0.5)



    ans = float("inf")

    for i in range(1, loop + 1):

        if N % i == 0:

            j = N // i

            tmp = i + j - 2



            if tmp < ans:

                ans = tmp

    print(ans)





if __name__ == "__main__":

    main()
def func(N):

    loop = int(N ** 0.5)



    ans = float("inf")

    for i in range(1, loop + 1):

        if N % i:

            continue

        j = N // i

        tmp = i + j - 2

        ans = min(ans, tmp)

    

    return ans





if __name__ == "__main__":

    N = int(eval(input()))

    

    print((func(N)))
def main():
    N = int(eval(input()))
    loop = int(N**0.5)
    ans = float("inf")
    for i in range(1, loop + 1):
        if N % i == 0:
            j = N // i
            tmp = i + j - 2
            if tmp < ans:
                ans = tmp
    print(ans)


if __name__ == "__main__":
    main()

def func(N):
    loop = int(N**0.5)
    ans = float("inf")
    for i in range(1, loop + 1):
        if N % i:
            continue
        j = N // i
        tmp = i + j - 2
        ans = min(ans, tmp)
    return ans


if __name__ == "__main__":
    N = int(eval(input()))
    print((func(N)))

-def main(): -    N = int(eval(input())) +def func(N): -        if N % i == 0: -            j = N // i -            tmp = i + j - 2 -            if tmp < ans: -                ans = tmp -    print(ans) +        if N % i: +            continue +        j = N // i +        tmp = i + j - 2 +        ans = min(ans, tmp) +    return ans -    main() +    N = int(eval(input())) +    print((func(N)))