import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N = lread();
    auto d0 = divisor(N - 1);
    auto d1 = divisor(N);
    // writeln(d0);
    // writeln(d1);s
    bool[long] dict;
    foreach (d; d0)
        dict[d] = true;
    long ans = d0.length - 1;
    foreach (d; d1)
    {
        if (d == 1 || (d in dict) || N < d)
            continue;
        long n = N;
        while (0 < n && n % d == 0)
            n /= d;
        if (n % d == 1)
        {
            // writeln(d);
            ans++;
        }
    }
    writeln(ans);
}

long[] divisor(long N)
{
    long[] ret;
    foreach (i; 1 .. N + 1)
    {
        if (N < i * i)
            break;
        if (N % i == 0)
        {
            ret ~= i;
            if (i * i != N)
                ret ~= N / i;
        }
    }
    return ret;
}
