require 'pp'

def gets; ARGF.gets; end

class Solver

  def initialize
  end

  def main
    n = gets.chomp.to_i

    sn = Math.sqrt(n)

    min_dist = 1000000000000
    1.upto(sn) do |i|
      d, r = n.divmod(i)
      next if r != 0

      dist = i + d - 2
      if dist < min_dist
        min_dist = dist
      end
    end

    puts min_dist
  end
end

if __FILE__ == $0
  Solver.new.main
end
