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
39
40
41
42
43
44
45
46
47
48
49
#include<iostream>
#include<cmath>
#include<set>
#include<utility>

using namespace std;

int possiblePins = 0;
set<pair<int,int> > middle;

void dividers(int num, int n) {
    for (int i = 2; i<=sqrt(num); i++) {
        if (num%i == 0) {
            int a = n/num;
            if (i >= 3) {
                if (middle.find(make_pair(a*num/i, a)) == middle.end()) {
                    middle.insert(make_pair(a*num/i, a));
                    possiblePins++;
                }
            }

            if (middle.find(make_pair(a*i, a)) == middle.end()) {
                middle.insert(make_pair(a*i, a));
                possiblePins++;
            }
        }
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;

    for (int i = 1; i<=sqrt(n); i++) {
        if (n%i == 0) {
            if (i >= 6) {
                dividers(i-1, n);
            }
            dividers(n/i-1, n);
        }
    }

    cout << possiblePins << "\n";

    return 0;
}