1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>
#include <cmath>

using namespace std;

long r = 0;

void factor(long x) {
    if (x <= 4)
        return;
    if (x % 2 == 0)
        r += 1;
    long sx = sqrt(x);
    for (long y = 3; y <= sx; y++)
        if (x % y == 0)
            r += y * y == x ? 1 : 2;
}

long answer(long n) {
    r = 0;
    long sn = sqrt(n);
    for (long p = 1; p <= sn; p++) {
        if (n % p == 0) {
            factor(p - 1);
            if (p * p != n)
                factor(n / p - 1);
        }
    }
    return r;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long n;
    cin >> n;
    cout << answer(n) << "\n";
}