n = int(input())

# コピー
m = n

# 素因数分解
a = []
while n % 2 == 0:
    a.append(2)
    n //= 2
f = 3
while f * f <= n:
    if n % f == 0:
        a.append(f)
        n //= f
    else:
        f += 2
if n != 1:
    a.append(n)


x=1

for i in a[::-1]:
  x *= i
  if x*x >= m:
    break

y = m // x
ans = x + y -2

print(ans)

