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

int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

int main() {
    int p, q;
    cin >> p >> q;
    q /= gcd(p, q);
    for (int i = 2; i * i <= q; i++) {
        while (q % (i * i) == 0) q /= i;
    }
    cout << q << endl;
    return 0;
}

