import java.lang.Math.sqrt

fun main(args: Array<String>) = yorukatsu16e()

fun yorukatsu16e() {
    val n = readLine()!!.toLong()

    val divisors = divisors(n) - 1

    val answer = divisors.count {
        var currN = n
        while (currN % it == 0L) currN /= it
        currN % it == 1L
    } + (divisors(n - 1) - 1).size

    println(answer)
}

private fun divisors(n: Long): Set<Long> {
    val divisors = mutableSetOf<Long>()
    for (i in 1..sqrt(n.toDouble()).toLong()) if (n % i == 0L) divisors.addAll(listOf(i, n / i))
    return divisors
}
