import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

Tuple!(N, N)[] prime_division(N)(N n)
{
    Tuple!(N, N)[] res;
    foreach (N i; 2..10^^6+1) {
        if (n%i == 0) {
            N cnt;
            while (n%i == 0) {
                ++cnt;
                n /= i;
            }
            res ~= tuple(i, cnt);
        }
    }
    if (n != cast(N)1) res ~= tuple(n, cast(N)1);
    return res;
}

void main()
{
    auto N = readln.chomp.to!long;
    if (N == 2) {
        writeln(1);
        return;
    }
    auto ps = prime_division(N);
    int res;
    for (long d = 2; d^^2 <= N; ++d) {
        if (ps.length > 0 && ps[0][0] == d) {
            foreach (x; 1..ps[0][1]+1) {
                auto dd = d^^x;
                auto n = N;
                while (n % dd == 0) n /= dd;
                if (n % dd == 1) {
                    ++res;
                }
            }
            ps = ps[1..$];
        } else {
            if (N % d == 1) {
                ++res;
            }
            if ((N-1) % d == 0) {
                ++res;
            }
        }
    }
    bool skip;
    foreach (p; ps) {
        auto d = p[0];
        if (d == N) skip = true;
        foreach (x; 1..p[1]+1) {
            if ((N / d^^x) % d^^x == 1) {
                ++res;
            }
        }
    }
    if (!skip) ++res;
    writeln(res+1);
}