import scala.math.sqrt

object Main extends App {
  
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextLong()
  val ans = (1 to math.sqrt(n).toInt).collect { case i if n % i == 0 => i + (n / i) - 2 }
  println(ans.min)
}
