Problem:
Score : 300 points

Problem Statement

There are N integers a_1, a_2, ..., a_N not less than 1.
The values of a_1, a_2, ..., a_N are not known, but it is known that a_1 \times a_2 \times ... \times a_N = P.

Find the maximum possible greatest common divisor of a_1, a_2, ..., a_N.

Constraints

1 \leq N \leq 10^{12}

1 \leq P \leq 10^{12}

Input

Input is given from Standard Input in the following format:

N P

Output

Print the answer.

Sample Input 1

3 24

Sample Output 1

2

The greatest common divisor would be 2 when, for example, a_1=2, a_2=6 and a_3=2.

Sample Input 2

5 1

Sample Output 2

1

As a_i are positive integers, the only possible case is a_1 = a_2 = a_3 = a_4 = a_5 = 1.

Sample Input 3

1 111

Sample Output 3

111

Sample Input 4

4 972439611840

Sample Output 4

206

Solution in C++14 (GCC 5.4.1) (judge verdict: Accepted)

#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
void dump(){cout<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cout<<h<<", ";dump(forward<Ts>(t)...);}
template<class T> istream &operator>>(istream&input,vector<T>&v){for(auto &elemnt:v)input>>elemnt;return input;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
void solve1();void solve2();
int main(){solve1();return 0;}

std::vector<std::pair<ll,ll>> prime_factorization(ll n){
  std::vector<std::pair<ll,ll>> factor;
  for(ll p=2;p*p<=n;++p){
    if(n%p!=0)continue;
    ll num=0;
    while(n%p==0){
      num++;
      n/=p;
    }
    factor.emplace_back(p,num);
    if(n==1)return factor;
  }
  if(n!=1)factor.emplace_back(n,1);
  return factor;
}
std::vector<ll> divisor(ll n){
  std::vector<ll> div;
  for(ll p=1;p*p<=n;++p){
    if(n%p==0){
     div.push_back(p);
     if(p*p!=n)div.push_back(n/p);
    }
  }
  return div;
}

ll mypow(ll n,ll p){
  ll ans = 1LL;
  while(p){
    if(p&1)ans*=n;
    n*=n;p>>=1;
  }
  return ans;
}

void solve2(){
  ll n,p;
  cin>>n>>p;
  ll ans = 0;
  auto div = divisor(p);
  sort(div.begin(),div.end());
  auto is_contain =[](vector<ll>const& v,ll n){
    auto itr = lower_bound(v.begin(),v.end(),n);
    return *itr==n;
  };
  for(ll i=1;mypow(i,n)<=p;++i){
    if(is_contain(div,i))ans = i;
  }
  cout<<(ans)<<endl;
}

void solve1(){

  ll n,p;
  cin>>n>>p;

  auto a = prime_factorization(p);
  auto b = divisor(p);
  sort(a.begin(),a.end(),greater<>());
  sort(b.begin(),b.end());
  auto is_contain =[](vector<ll>const& v,ll n){
    auto itr = lower_bound(v.begin(),v.end(),n);
    return *itr==n;
  };
  ll ans = 1LL;
  using pll = pair<ll,ll>;
  priority_queue<pll> que;
  for(auto const& elm:a)que.emplace(elm);
  while(!que.empty()){
    pll elm = que.top();
    que.pop();
    if(elm.second>=n&&pow(ans*elm.first,n)<=p&&is_contain(b,ans*elm.first)){
      ans*=elm.first;
      if(elm.second-n>=n)que.emplace(pll(elm.first,elm.second-n));
    }
  }
  cout<<(ans)<<endl;

}