def solve(n)
  sqrt_n = Math.sqrt(n).floor
  
  m = 1
  sqrt_n.downto(1).each do |i|
    if n % i == 0
      m = i
      break
    end
  end
  
  (m - 1) + (n / m - 1)
end

n = STDIN.gets.chomp.to_i
puts solve(n)
