fun main(args: Array<String>) {
    val N = nextLong()
    var ans = 0
    divisor(N).drop(1).forEach { x ->
        var w = N
        while (w % x == 0L) w /= x
        if (w % x == 1L) ans += 1
    }
    ans += divisor(N - 1).drop(1).size
    println(ans)
}

fun divisor(value: Long) =
    (1 .. Math.sqrt(value.toDouble()).toLong())
        .filter { value % it == 0L }
        .map { listOf(it, value / it) }
        .flatten()
        .distinct()
        .sorted()


fun next() = readLine()!!
fun nextLong() = next().toLong()

