#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<int ,P> P3;
typedef pair<P ,P> PP;
const ll MOD = ll(1e9+7);
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-6;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

ll gcd(ll p, ll q){
    if(p%q==0) return q;
    else return gcd(q, p%q);
}

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

