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

int gcd(int x, int y) {
	if (x<=y) return gcd(y, x);
	if (x%y == 0) return y;
	else return gcd(y, x%y);
}

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