require 'prime'
class Prime
    def each_divisor(n, &block)
        pf = prime_division(n)
        num = -> { pf.inject(1) { |prod, (_, exp)| prod * exp.succ } }
        Enumerator.new(num) { |y| __each_divisor__(1, pf, &y.method(:<<)) }
                  .tap { |enum| enum.each(&block) }
    end
    private def __each_divisor__(d, ary, &block)
        return yield(d) if ary.empty?

        ary = ary.dup
        prime, exp = ary.pop
        0.upto(exp) { __each_divisor__(d, ary, &block); d *= prime }
    end
end
a=gets.to_i
r=Math.sqrt(a)
prime = Prime.instance
p=prime.each_divisor(a).to_a.sort
x=p.bsearch{|i| i>r or ((i-r).abs/i.abs)<=Float::EPSILON && ((r-i).abs/r.abs)<=Float::EPSILON}
y=a/x
puts x+y-2
