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
#include <iostream>
#include <cmath>

using namespace std;

long divider(long n, long fromWhen) {
    long p=fromWhen;
    long sqrn = sqrt(n);
    while(p<=sqrn)
    {
	if(n%p==0) return p;
	p++;
    }
    return 0;
    
}

int main(){
    long n,output=0;
    cin >> n;
    
    //---for a=1

    long temp_n=n-1,p,q,d=2,da=1,dividerNumber=0,dividerEqual2=0,dividerEqualQ=0,a=1;

    while(a!=0)
    {

    a=divider(n,da);
    if(a==0) break;
//    cout << "a " <<a<<endl;
    temp_n=(n-a)/a;

//    cout <<"temp_n" << temp_n<<endl;
    dividerNumber=0;
    dividerEqual2=0;
    dividerEqualQ=0;
    da=a+1;
    p=1;
    d=2;
    while(p!=0){
	p=divider(temp_n,d);
	if(p==2) dividerEqual2=1;;
	if(p == 0) break;
	if(temp_n/p ==p )dividerEqualQ=1;
//	cout<<" p= "<<endl;
	//temp_n/=p;
	d=p+1;
	dividerNumber++; 
//	cout<<" p= "<<p <<" temp_n=" << temp_n << " dividerNumer =" <<dividerNumber<<endl;
    }
//    dividerNumber++;
//    cout <<"how many dividers"<<dividerNumber<<endl;

    output+=2*dividerNumber-dividerEqual2-dividerEqualQ;

    //---for a>1
    a=n/a;
    temp_n=(n-a)/a;
//    cout <<"temp_n" << temp_n<<endl;
    dividerNumber=0;
    dividerEqual2=0;
    dividerEqualQ=0;
    p=1;
    d=2;
    while(p!=0){
	p=divider(temp_n,d);
	if(p==2) dividerEqual2=1;;
	if(p == 0) break;
	if(temp_n/p ==p )dividerEqualQ=1;
//	cout<<" p= "<<endl;
	//temp_n/=p;
	d=p+1;
	dividerNumber++;
//	cout<<" p= "<<p <<" temp_n=" << temp_n << " dividerNumer =" <<dividerNumber<<endl;
    }
//    dividerNumber++;
//    cout <<"how many dividers"<<dividerNumber<<endl;

    output+=2*dividerNumber-dividerEqual2-dividerEqualQ;

    //---for a>1



    }


//    cout<<"i="  <<" test"<< n << "divider = "<< divider(n,2)<<endl;

//    cout <<"output = " << output << endl;
    cout<<output<<endl;
    return 0;
}