import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

def main():

    N = int(eval(input()))

    ans = 10e+12 

    max_sq = int(math.sqrt(N)+1)

    for i in range(1, max_sq):

        if N % i == 0:

            j = N // i

            ans = min(ans, i+j-2)

    print(ans)

main()



import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

def main():

    N = int(eval(input()))

    ans = N-1

    max_sq = int(math.sqrt(N)+1)

    for i in range(1, max_sq):

        if N % i != 0:

            continue

        j = N // i

        ans = min(ans, i+j-2)

    print(ans)

main()



import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools


def main():
    N = int(eval(input()))
    ans = 10e12
    max_sq = int(math.sqrt(N) + 1)
    for i in range(1, max_sq):
        if N % i == 0:
            j = N // i
            ans = min(ans, i + j - 2)
    print(ans)


main()

import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools


def main():
    N = int(eval(input()))
    ans = N - 1
    max_sq = int(math.sqrt(N) + 1)
    for i in range(1, max_sq):
        if N % i != 0:
            continue
        j = N // i
        ans = min(ans, i + j - 2)
    print(ans)


main()

-    ans = 10e12 +    ans = N - 1 -        if N % i == 0: -            j = N // i -            ans = min(ans, i + j - 2) +        if N % i != 0: +            continue +        j = N // i +        ans = min(ans, i + j - 2)