object Main extends App {

  val n = scala.io.StdIn.readLong()


  def solve(): Long =  {
    for(i <- Math.floor(Math.sqrt(n)).toLong to 1 by -1) {
      if(n % i == 0) return (i-1) + (n/i) - 1
    }
    n - 1
  }

  println(solve)

}
