N = gets.chomp.to_i
 
answer = 10**12
 
  (1..N).each do |i|
    if N % i != 0
      next
    else
      j = N / i
      answer_candidate = i + j - 2
      if answer_candidate < answer
        answer = answer_candidate
      end
    end
 
  end

 
p answer