/*
    給出n,問滿足phi(k) = n的k的個數,其中k的素因子個數<=3    n<2^31
    歐拉函數
    phi(k) = k(1-1/p1)(1-1/p2)(1-1/p3)
             = (p1-1)p1^x*(p2-1)p2^y*(p3-1)p3^z
     phi(1) = 1

    比賽時打算篩素數(篩到sqrt(2^31)),枚舉p1,p2,p3
    有問題的,比如 n = (3-1) * p
    當n很大時,這樣p就是一個很大的數了,而素數表沒有,就枚舉不到了!

    問了ACOrz,他的代碼很神奇呀
    因為n = (p1-1)p1^x*(p2-1)p2^y*(p3-1)p3^z
    用sqrt(n)枚舉(pi-1)
        if(n%(pi-1) && isPrime(pi))加入pi
    然后就dfs出最多3個數,讓 (p1-1)p1^x*(p2-1)p2^y*(p3-1)p3^z = n
    
    注意的是phi(1) = 1
    所以n=1時,滿足條件的有2個,即k=1,2
    
    ACOrz的代碼很簡潔,下面是我按照我的風格模仿他寫的
    注意枚舉的是(pi - 1),不是n的素因子 !!!
*/

#include
<iostream>
#include
<cstring>
#include
<map>
#include
<algorithm>
#include
<stack>
#include
<queue>
#include
<cmath>
#include
<string>
#include
<cstdlib>
#include
<vector>
#include
<cstdio>
#include
<set>
#include
<list>
#include
<numeric>
#include
<cassert>
#include
<ctime>

using namespace std;

vector
<int> prime;
int ans;

bool isPrime(int n){
    
for(int p = 2; p <= n/p ; p++){
        
if(n % p == 0){
            
return false;
        }

    }

    
return true;
}


void dfs(int next, vector<int> with, int n){
    
int nn = n;
    
bool can = true;
    
for(vector<int>::iterator it = with.begin() ; it != with.end() ; it++){//檢查合法性
        if(n % (*it-1== 0)    {
            n 
/= (*it-1);
        }
else {
            can 
= false;
            
break;
        }

    }

    
if(can){
        
//with可以為空!!!
        for(vector<int>::iterator it = with.begin() ; it != with.end() ; it++){
            
while(n % *it == 0){
                n 
/= *it;
            }

        }

        
if(n == 1)ans++;//特殊情況是with為空,但原始的n為1
        if(with.size() == 3){
            
return;
        }

        
for(int i = next ; i < prime.size(); i++){//擴展
            with.push_back(prime[i]);
            dfs(i
+1, with, nn);
            with.pop_back();
        }

    }
    
}


int main()
{
#ifndef ONLINE_JUDGE
    
//freopen("in","r",stdin);
#endif

    
for(int n; ~scanf("%d"&n); ){
        prime.clear();
        
for(int i = 1 ; i <= n / i; i++){
            
if(n % i == 0){
                
if(isPrime(i+1)){
                    prime.push_back(i
+1);
                }

                
if(n/!= i && isPrime(n/i+1)){
                    prime.push_back(n
/i+1);
                }

            }

        }

        ans 
= 0;
        dfs(
0, vector<int>(), n);
        printf(
"%d\n", ans);
    }

    
return 0;
}