def divisor(num)
    result = []
    i = 1
    while i <= num**(0.5) do
      remainder = num % i
      if remainder == 0
        result << i
      end 
      i += 1
    end
    return result
end

num = gets.to_i
divisions = divisor(num)

distance_lists = []

for d in divisions do
  width_count = (d - 1)
  vertical_count = (num / d - 1)
  distance_lists << width_count + vertical_count
end

ans = distance_lists.min 
puts(ans)