object Main extends App {
    val N = readLong
    val max = Math.sqrt(N)
    def calc(c:Long, i:Long, j:Long):Array[Long] =  {
        if(c + 1 > max) {
            Array(i,j)
        } else {
            var ji = j
          	var ii = i
            if(N%c==0) {
                ji = N / c
                ii = c
            }
            calc(c+1, ii , ji)
        }
    }
    var ans = calc(1, 0 ,0)
    println(ans(0) + ans(1) - 2)        

}