s = input().split() #標準入力　sに値を入れる

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

n = int(s[0])
newdivisors = make_divisors(n)
l = len(newdivisors)
n1 = newdivisors[l // 2 - 1]
n2 = newdivisors[l // 2]
ans = n1 + n2 - 2
print(ans)
