#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

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

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int p,q; cin >> p >> q;
    int r = q / gcd(p,q);
    int s = r;
    vector<int> A;
    for (int i = 2; i*i <= r; i++) {
        if (s % i == 0) {
            A.emplace_back(i);
            while (s % i == 0) s /= i;
        }
    }
    if (s != 1) A.emplace_back(s);
    int ans = 1;
    rep(i,A.size()) ans *= A[i];

    cout << ans << endl;
}
