require 'complex'

N = gets.to_i

ans = Float::INFINITY
sqrt = Math.sqrt(N)

(1..N).each do |i|
    break if i > sqrt
    div, mod = N.divmod(i)
    if mod == 0
        ans = [div + i,ans].min
    end
end

puts ans-2