#include <bits/stdc++.h>
using namespace std;
map<long long, long long> prime;
void factrization(long long N) {
  for (long long i = 2; i * i <= N; i++) {
    while (N % i == 0) {
      prime[i]++;
      N /= i;
    }
  }
  if (N != 1) {
    prime[N]++;
  }
}
int main(void) {
  long long N, pair<long long, long long>;
  cin >> N >> pair<long long, long long>;
  long long ans = 1;
  factrization(pair<long long, long long>);
  for (auto itr = prime.begin(); itr != prime.end(); itr++) {
    if (itr->second >= N) {
      ans *= itr->first * (itr->second / N);
    }
  }
  cout << ans << endl;
}
