n = gets.chomp.to_i
kazu = n ** 0.5
meyasu = kazu.ceil
ans = Float::INFINITY
meyasu.downto(1) do |i|
    amari = n % i
    j = n / i
    if amari == 0 
        goukei = i + j
        ans = [ans,goukei].min
    end 

end
puts ans - 2