#include <bits/stdc++.h>
using namespace std;
map<long long, int> soinsuBunkai(long long n) {
  map<long long, int> ret;
  ret[1] = 1;
  while (n % 2 == 0) {
    ret[2]++;
    n /= 2;
  }
  while (n > 1) {
    long long now = n;
    for (long long i = 3; i * i <= n; i += 2) {
      while (n % i == 0) {
        ret[i]++;
        n /= i;
      }
    }
    if (now != n) continue;
    ret[n]++;
    n = 1;
  }
  return ret;
}
long long N, p;
int main() {
  cin >> N >> p;
  auto soinsu = soinsuBunkai(p);
  long long ans = 1;
  for (auto it = soinsu.begin(); it != soinsu.end(); it++) {
    ans *= max((long long)(1), it->first * (it->second / N));
  }
  cout << ans << endl;
  return 0;
}
