def chmin(a, b)
    a > b ? b : a
  end
n = gets.to_i
sum = 10000000000000
(1..Math.sqrt(n)).each do |i|
    if n % i == 0
        k = n / i
        sum = chmin(sum, (i - 1) + (k - 1))
    end
end
puts sum
