#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

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

int main() {
  int p, q;
  cin>>p>>q;

	q = q/gcd(p,q);  /*??????????´??????????????????????*/

	//int qq = q/gcd(p,q);
	int qq = q;
	long long ans = 1;
	for(int j=2; j*j<=qq; j++){
		if(qq % j == 0){
			ans *= j;
			while(qq % j == 0){
				qq /= j;
			}
		}
	}
	if(qq != 1) ans *= qq;

	cout<<ans<<endl;

  return 0;
}