module f;

import std.conv, std.stdio;
import std.algorithm, std.array, std.string, std.range;

void main()
{
    auto n = readln.chomp.to!long;
    // (qk+1) k^r = n

    auto answer = (n-1).countFactors - 1;
    // r = 0:
    //   qk+1 = n <=> k | (n-1)

    foreach (f; n.factors)
    {
        if (f == 1) continue;
        auto t = n;
        while (!(t % f))
            t /= f;
        answer += ((t % f) == 1);
    }
    // otherwise:
    //  (k | n) and (k | (n/k^r-1))

    answer.writeln;
}

auto countFactors(long n)
{
    return reduce!((a, b) => a * (b + 1))(1, 
            n.primeFactors.group.map!(_ => _[1]));
}
long[] factors(long n)
{
    auto powers = n.primeFactors.chunkBy!((a, b) => a == b).map!pwrs.array;
    stderr.writeln(powers);
    return powers.reduce!((a, b) => a.cartesianProduct(b).map!(_ =>
            _[0] * _[1]).array);
}
long[] pwrs(R)(R r)
{
    long[] ret;
    ret ~= 1;
    foreach (e; r)
        ret ~= ret[$-1] * e;
    return ret;
}
auto primeFactors(long n)
{
    long[] ret;
    long p = 1;
    while (p * p < n)
    {
        p += 1;
        while (!(n % p))
        {
            ret ~= p;
            n /= p;
        }
    }
    if (n != 1)
        ret ~= n;
    stderr.writeln(ret);
    return ret;
}