N = gets.chomp.to_i

answer = 10**12

if N > 10**6
  answer = N - 1
else
  (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
end

p answer

