Go: package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"
)

func main() {
	fmt.Println(resolve(parseProblem(os.Stdin)))
}

func parseProblem(r io.Reader) int {
	const (
		initialBufSize = 100000
		maxBufSize     = 1000000
	)
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	p, q := scanInt(sc), scanInt(sc)
	base := 1
	d := newRational(p, q).denomi
	for k := range primeFactories(d) {
		base *= k
	}
	return base
}

func isPrime(n int) bool {
	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			return false
		}
	}
	return true
}

func eratosthenes(n int) []bool {
	t := make([]bool, n)
	for i := 2; i < len(t); i++ {
		t[i] = true
	}
	for i := 2; i < len(t); i++ {
		if !t[i] {
			continue
		}
		for j := 2; j*i < len(t); j++ {
			t[j*i] = false
		}
	}
	return t
}

func primes(n int) chan int {
	ch := make(chan int)
	go func() {
		t := eratosthenes(n)
		for i := 2; i < len(t); i++ {
			if !t[i] {
				continue
			}
			ch <- i
		}
		close(ch)
	}()
	return ch
}

func primeFactories(n int) (terms map[int]int) {
	terms = map[int]int{}
	num := n
	for f := 2; f*f <= n; f++ {
		if num%f != 0 {
			continue
		}
		ex := 0
		for num%f == 0 {
			num /= f
			ex++
		}
		terms[f] = ex
	}
	if num > 1 {
		terms[num] = 1
	}
	return
}

type rational struct {
	frac, denomi int
	neg          int
}

func newRational(frac, denomi int) rational {
	r := rational{frac: frac, denomi: denomi}
	r.canonicalize()
	return r
}

func ratMul(x, y rational) rational {
	r := rational{
		frac:   x.frac * y.frac,
		denomi: x.denomi * y.denomi,
	}
	r.canonicalize()
	return r
}

func ratDiv(x, y rational) rational {
	return ratMul(x, ratInv(y))
}

func ratInv(x rational) rational {
	return rational{frac: x.denomi, denomi: x.frac}
}

func ratAdd(x, y rational) rational {
	r := rational{
		frac:   x.frac*y.denomi + y.frac*x.denomi,
		denomi: x.denomi * y.denomi,
	}
	r.canonicalize()
	return r
}

func ratSub(x, y rational) rational {
	return ratAdd(x, rational{frac: -y.frac, denomi: y.denomi})
}

func (r rational) Float64() float64 {
	b := float64(r.frac) / float64(r.denomi)
	if r.neg == 1 {
		return -b
	}
	return b
}

func (r rational) String() string {
	b := fmt.Sprintf("%d/%d", r.frac, r.denomi)
	if r.neg == 1 {
		return "-" + b
	}
	return b
}

func (r rational) equal(other rational) bool {
	r.canonicalize()
	other.canonicalize()

	return r.neg == other.neg &&
		r.frac == other.frac &&
		r.denomi == other.denomi
}

func (r *rational) canonicalize() {
	if r.frac < 0 {
		r.neg ^= 1
		r.frac = -r.frac
	}
	if r.denomi < 0 {
		r.neg ^= 1
		r.denomi = -r.denomi
	}
	d := gcd(r.frac, r.denomi)
	r.frac /= d
	r.denomi /= d
}

func nextRational(sc *bufio.Scanner) rational {
	s := nextString(sc)
	i := strings.Index(s, ".")
	if i != -1 {
		decimalDigit := len(s) - i - 1
		fr, _ := strconv.Atoi(strings.Replace(s, ".", "", 1))
		return newRational(fr, int(math.Pow10(decimalDigit)))
	}
	i = strings.Index(s, "/")
	if i != -1 {
		fr, _ := strconv.Atoi(s[0:i])
		de, _ := strconv.Atoi(s[i+1 : len(s)])
		return newRational(fr, de)
	}
	fr, _ := strconv.Atoi(s)
	return newRational(fr, 1)
}
func gcd(a, b int) int {
	for b > 0 {
		t := a / b
		a, b = b, a-t*b
	}
	return a
}
func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	a, _ := strconv.Atoi(sc.Text())
	return int(a)
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func resolve(n int) int {
	return n
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

C++: #include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

LL gcd(LL x, LL y){
  while(x%y){
    LL tmp = x%y;
    x=y;
    y=tmp;
  }
  return y;
}

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

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
	long long p,q;
	cin >> p >> q;
	long long P=p,Q=q;
	while(p%q!=0){
		p=p%q;
		swap(p,q);
	}
	long long va=Q;
	P/=q;
	Q/=q;
	for(long long i=2;i*i<=va;i++)
		while(Q%i==0&&P<(Q/i))
			Q/=i;
	cout << Q << endl;
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int p,q,x,test;
  cin>>p>>q;
  if(p<q) swap(p,q);
  test=p;
  while(1){
    if(p%q!=0){
      x=p%q;
      p=q;
      q=x;
      continue;
    }
    break;
  }
  int tmp=test/q;
  int ans=tmp;
  for(int i=2;i<=sqrt(tmp)+1;++i){
    if(tmp%i==0){
      int a=tmp;
      while(a){
        if(a%i) break;
        else if(a/i==1) ans=i;
        a/=i;
      }
      if(ans!=1) break;
    }
  }
  cout<<ans<<endl;
  return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<map>
#include<vector>
#include<set>
#include<cmath>
using namespace std;

int main(){
  int p, q;
  std::cin >> p >> q;
  int gcd = __gcd(p, q), ans = 1;
  p /= gcd;
  q /= gcd;
  set<int> s;
  for (int i = 2; i*i <= q; i++) {
    while(q%i == 0)s.insert(i), q/=i;
  }
  s.insert(q);
  for (auto i: s) {
    ans *= i;
  }
  std::cout << ans << std::endl;
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;

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



int main(){
  int a,b;
  cin>>a>>b;
  int n=yaku(a,b);
  a/=n;
  b/=n;
  int ans=1;
  //cout<<a<<" "<<b<<endl;
  
  for(int i=2;b!=1;i++){
    if(b%i==0){
      ans*=i;
    while(b%i==0){
      b/=i;
    }
    }
  }

  
  cout<<ans<<endl;
  
  
  return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
const double EPS = 1e-8;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int p, q; cin >> p >> q;
    int target = q / __gcd(p, q);
    for(int i = 2; i * i <= target; i++)
    {
        while(target % (i * i) == 0) target /= i;
    }
    cout << target << endl;
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
        long long p,q;
        cin >> p >> q;
        for(long long i=2;i*i<=q;i++){
                if(p%i==0&&q%i==0){
                        do{
                                p/=i;
                                q/=i;
                        }
                        while(p%i==0&&q%i==0);
                }
        }
        for(int i=2;i*i<=q;i++){
                if((int)pow(p,0.5)==(double)pow(p,0.5)&&(int)pow(q,0.5)==(double)pow(q,0.5)){
                	p/=pow(p,0.5);
                	q/=pow(q,0.5);
                }
        }
        cout << q << endl;
        return 0;
}