N = gets.to_i

div1 = []
div2 = []
for i in 1..(N ** 0.5 + 1) do
  if N % i == 0 then
    div1.push(i)
    div2.push(N/i)
  end
end
  
min = 10 ** 13
for i in 1..div1.length do
  s = div1[i-1] + div2[i-1] - 2
  if s < min then
    min = s
  end
end
  
print min