#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 DivisorsPower { public:
	long long findArgument(long long n)
	{
		LL cand = 1LL<<62;
		for(int p=2; p<=63; ++p) {
			LL xc = LL(pow(double(n), 1.0/p));
			for(LL x=max(2LL,xc-100); x<=min(xc+100,n); ++x)
				if(ok(x,n))
					cand = min(cand, x);
		}
		return (cand==(1LL<<62) ? -1 : cand);
	}

	int d(LL x)
	{
		int cnt = 1;
		for(int p=2; p*p<=x; ++p)
			if(x%p==0) {
				int k = 0;
				while(x%p==0) x/=p, ++k;
				cnt *= 1+k;
			}
		if(x>1)
			cnt *= 2;
		return cnt;
	}

	int ilog(LL x, LL n)
	{
		int cnt = 0;
		while(n%x==0) 
			n/=x, ++cnt;
		return n>1 ? -1 : cnt;
	}


	bool ok(LL x, LL n)
	{
		return ilog(x, n) == d(x);
	}
};

// 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 long long& Expected, const long long& 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(_, DivisorsPower().findArgument(n));}
int main(){

CASE(0)
	long long n = 4LL; 
	long long _ = 2LL; 
END
CASE(1)
	long long n = 10LL; 
	long long _ = -1LL; 
END
CASE(2)
	long long n = 64LL; 
	long long _ = 4LL; 
END
CASE(3)
	long long n = 10000LL; 
	long long _ = 10LL; 
END
CASE(4)
	long long n = 2498388559757689LL; 
	long long _ = 49983883LL; 
END
/*
CASE(5)
	long long n = LL; 
	long long _ = LL; 
END
CASE(6)
	long long n = LL; 
	long long _ = LL; 
END
*/
}
// END CUT HERE
