#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 BigFatInteger { public:
	int minOperations(int A, int B)
	{
		vector<int> s;
		for(int p=2; p*p<=A; ++p)
		{
			int c = 0;
			while(A%p==0) A/=p, ++c;
			if(c) s.push_back(c*B);
		}
		if(A>1)
			s.push_back(1*B);

		int cnt = s.size();
		vector<int> cur(s.size(), 1);
		while(cur != s)
		{
			for(int i=0; i<s.size(); ++i)
				cur[i] = min(cur[i]*2, s[i]);
			++cnt;
		}
		return cnt;
	}
};

// 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(_, BigFatInteger().minOperations(A, B));}
int main(){

CASE(0)
	int A = 6; 
	int B = 1; 
	int _ = 2; 
END
CASE(1)
	int A = 162; 
	int B = 1; 
	int _ = 4; 
END
CASE(2)
	int A = 999983; 
	int B = 9; 
	int _ = 5; 
END
CASE(3)
	int A = 360; 
	int B = 8; 
	int _ = 8; 
END
CASE(4)
	int A = 1000000; 
	int B = 1000000; 
	int _ = -1; 
END
CASE(5)
	int A = 2*3*5*7*11*13*17; 
	int B = 1000000; 
	int _ = -1; 
END

}
// END CUT HERE
