import java.util.Arrays
import java.util.ArrayList

const val MOD: Long = (1e9+7).toLong()
fun Double.format(digits: Int) = String.format("%.${digits}f", this)

fun primes(n: Int) : IntArray {
    /** Return a list of primes not more than n **/
    val primes: ArrayList<Int> = arrayListOf()

    val isPrime = Array(n+1, {true})
    for (i in 2..n) {
        if (isPrime[i]) {
            primes.add(i)
            var buf = i * 2
            while (buf <= n) {
                isPrime[buf] = false
                buf += i
            }
        }
    }
    return primes.toIntArray()
}

fun prime_fact(n: Long) : Map<Long, Int> {
    /** Return a map of the numbers of prime factors **/
    var cntprime: MutableMap<Long, Int> = mutableMapOf()

    var m = n
    for (i in primes(Math.sqrt(n.toDouble()).toInt())) {
        while (m % i == 0L) {
            cntprime[i.toLong()] = cntprime.getOrElse(i.toLong(), {0}) + 1
            m /= i
        }
    }
    if (m != 1L) {
        cntprime[m] = 1
    }

    return cntprime
}

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

    val facts = prime_fact(n)
    var res = 0L
    var list: ArrayList<Long> = arrayListOf(1)
    for ((k, v) in facts) {
        val list2 = Array(v+1, {Math.pow(k.toDouble(), it.toDouble()).toLong()})
        val list3: ArrayList<Long> = arrayListOf()
        for (e in list2) {
            list.forEach{
                list3.add(e * it)
            }
        }
        list = list3
    }
    for (e in list) {
        if (n/e < e-1) {
            res += e-1
        }
    }
    println(res)
}
