n = gets.to_i
ans = Float::INFINITY
divide = []
(n**(0.5)).ceil.times do |i|
    if n%(i+1)==0
        divide << i+1
    end
end

divide.each do |d|
    temp = (d-1)+(n/d)-1
    if ans > temp
        ans = temp
    end
end
puts ans