import java.util.*

fun main(args: Array<String>) {
    val N = readLine()!!.toLong()

    val fact = factors(N)

    println(
        fact.map { it - 1 }
            .filter { it != 0L && N / it == N % it }
            .sum()
    )

//    for (N in 1..200L) {
//        val list = ArrayList<Long>()
//        for (i in 2 until N) {
//            if (N % i == N / i) {
//                list.add(i)
//            }
//        }
//        println("$N: ${list.joinToString(" ")}")
//    }
}

fun factors(n: Long): List<Long> {
    var i = 1L
    val factors = ArrayList<Long>()

    while(i * i <= n) {
        if (n % i == 0L) {
            factors.add(i)

            if (n / i != i) {
                factors.add(n / i)
            }
        }
        i++
    }
    factors.sort()

    return factors
}
