def divisor(num)
    num_sqrt = Math.sqrt(num).floor
    (1..num_sqrt).select{ |i| num % i == 0 }
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)
