#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include<fstream>

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
using namespace std;

const LL MOD = 1000000007;// 10^9+7
const int INF = (1 << 30);


//変数
LL p, q;




//素因数分解
//in: number
//out: prime numbers
template<typename T>
vector<T> prime_factorization(T n)
{
	vector<T> res;
	T check = 2;

	while (check*check <= n) {
		if (n%check == 0) {
			n /= check;
			res.push_back(check);
		}
		else {
			check++;
		}
	}
	if (n != 1) res.push_back(n);
	sort(res.begin(), res.end());
	return res;
}


//最大公約数
//(ユークリッドの互除法)
//in: a,b
//out:  GCD(a,b)
template<typename T>
T GCD(T a, T b)
{
	if (a < b)swap(a, b);
	int r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}




//サブ関数
//入力
void input()
{
	cin >> p >> q;
}

//計算
void calc()
{
	LL gcd = GCD(p, q);
	q /= gcd;
	auto primes = prime_factorization(q);

	set<LL> primeKind;
	for (auto prime : primes)primeKind.insert(prime);

	LL res = 1;
	for (auto prime : primeKind)res *= prime;

	cout << res << endl;
}


//出力
void output()
{

}


//デバッグ
void debug()
{
	int N;
	cin>>N;
}


//メイン関数
int main()
{
	input();
	calc();
	output();
	debug();
	
	return 0;
}

