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
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#include <bits/stdc++.h>

using namespace std;

#define PB push_back
#define MP make_pair
#define fst first
#define snd second
#define LL long long
#define int LL
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define VI vector<int>
#define PII pair<int,int>
#define LD long double

template<class C> void minu(C& a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxu(C& a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<"="<<h<<","; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream &os, vector<T> V){
  os<<"[";for(auto vv:V)os<<vv<<",";return os<<"]";
} 

template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.fst << "," << P.snd << ")";
}


#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

void backtrack(int nr, int val, vector <int> &primes, vector <int> &cnt, vector <int> &divisors)
{
    if(nr>=(int)primes.size()) divisors.push_back(val);
    else
    {
        for(int i=0; i<=cnt[nr]; i++)
        {
            backtrack(nr+1, val, primes, cnt, divisors);
            val*=primes[nr];
        }
    }
}

int solve(int n)
{
    vector <int> primes;
    vector <int> cnt;
    vector <int> divisors;
    int tmp_n=n;
    for(int i=2; i<=n && i<100000; i++)
    {
        if(n%i==0)
        {
            primes.push_back(i);
            cnt.push_back(0);
            while(n%i==0)
            {
                cnt.back()++;
                n/=i;
            }
        }
    }
    if(n>1)
    {
        primes.push_back(n);
        cnt.push_back(1);
    }
    backtrack(0, 1, primes, cnt, divisors);
    n=tmp_n;
    debug(divisors);
    int wyn=0;
    for(int a:divisors)
    {
        cerr<<"srodek A "<<a<<endl;
        int sum=n/a-1;
        if(sum>=2 && a>=2)
        {
            cerr<<"sum "<<sum<<endl;
            wyn++;
        }
    }
    return wyn;
}

int32_t main()
{
    int n;
    scanf("%lld", &n);
    vector <int> primes;
    vector <int> cnt;
    vector <int> divisors;
    int tmp_n=n;
    for(int i=2; i<=n && i<100000; i++)
    {
        if(n%i==0)
        {
            primes.push_back(i);
            cnt.push_back(0);
            while(n%i==0)
            {
                cnt.back()++;
                n/=i;
            }
        }
    }
    if(n>1)
    {
        primes.push_back(n);
        cnt.push_back(1);
    }
    backtrack(0, 1, primes, cnt, divisors);
    int wyn=0;
    n=tmp_n;
    debug(divisors);
    for(int a:divisors)
    {
        cerr<<"DIV A "<<a<<endl;
        int sum=n/a-1;
        if(sum>=6)
        {
            cerr<<"sum "<<sum<<endl;
            wyn+=solve(sum);
        }
    }
    printf("%lld", wyn);
}