N = gets.to_i

max = 1
1.upto(N) do |i|
  if i * i > N
    max = i
    break
  end
end

ret = N - 1
max.downto(1) do |a|
  max.upto(N) do |b|
    if a * b == N
      tmp = a + b - 2
      if ret > tmp
        ret = tmp
      end
      break
    end
  end
end
puts ret