def divisor(num_sqrt)
    (1..num_sqrt).select{ |i| num_sqrt % i == 0 }
end

num = gets.to_i
num_sqrt = Math.sqrt(num).floor
divisions = divisor(num_sqrt)

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)
