#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <functional>
#include <complex>
#include <queue>
#include <stack>
#include <cmath>
#include <cassert>
#include <tuple>
using namespace std;
typedef long long LL;
typedef complex<double> CMP;

class DivisorSequences { public:
	int longest(int N)
	{
		int best = 0;
		if (N - 1 >= 2)
			best = 1 + cnt(N - 1);
		best = max(cnt(N), best);
		return best;
	}

	// The case starting with 2 or above
	int cnt(int N)
	{
		int best = 1; // [N]

		vector<int> divs;
		for (int p = 2; p*p <= N && p < N; ++p)
			if (N%p == 0) {
				divs.push_back(p);
				divs.push_back(N/p);
			}

		for (int s: divs)
			if ((N-s)/s>=2) {
				best = max(best, 1 + cnt((N - s) / s));
			}
		return best;
	}
};

// BEGIN CUT HERE
#include <ctime>
double start_time; string timer()
 { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v)
 { os << "{ ";
   for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
   os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; }
void verify_case(const int& Expected, const int& Received) {
 bool ok = (Expected == Received);
 if(ok) cerr << "PASSED" << timer() << endl;  else { cerr << "FAILED" << timer() << endl;
 cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } }
#define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock();
#define END	 verify_case(_, DivisorSequences().longest(N));}
int main(){

CASE(0)
	int N = 15; 
	int _ = 4; 
END
CASE(1)
	int N = 12; 
	int _ = 2; 
END
CASE(2)
	int N = 34; 
	int _ = 4; 
END
CASE(3)
int N = 1000000000;
int _ = -1;
END
CASE(4)
int N = 1 << 30;
int _ = -1;
END
CASE(5)
int N = 2 * 3 * 5 * 7 * 11 * 13 * 17 * 19 * 23;
int _ = -1;
END
}
// END CUT HERE
