require 'prime'

n = gets.to_i
dividors = n.prime_division
tmp = Array.new(dividors.size) { Array.new }
dividors.each_with_index do |(d1, d2), index|
  0.upto(d2) do |i|
    tmp[index] << d1 ** i
  end
end
ans = [[1]]
tmp.each do |t|
  a = ans.shift
  b = []
  t.each do |tt|
    a.each do |aa|
      b << tt * aa
    end
  end
  ans << b
end
mins = []
ans[0].each do |a|
  another = n / a
  answer = a + another - 2
  mins << answer
end
puts mins.min
