function gcd(arr) {
    var f = (a, b) => b ? f(b, a % b) : a
    var ans = arr[0]
    for (var i = 1; i < arr.length; i++) {
        ans = f(ans, arr[i]); 
    }
    return ans 
}

function primeFactorization(n) {
	var s = Math.floor(Math.sqrt(n));
	var r = 0;
	var result = Array();
	for (var i = 2;i <= s;i++) {
		if ((n % i) == 0) {
			r = 0
			do {
				r++
				n = n / i;
			} while ((n % i) == 0);
			result.push({num:i, r:r});
		}
	}
	if (n > s) {
		result.push({num:n, r:1});
	}
	return result;
}



function main(arg) {
	var header = arg.split("\n")[0].split(" ")

	var N = Number(header[0])
	var P = Number(header[1])

	if (N === 1) {
		console.log(P)
		return
	}

	if (P === 1) {
		console.log(1)
		return
	}

	var num = primeFactorization(P)
	var max = Number.MIN_VALUE

	var arr = new Array(N)
	for (var i = 0; i < arr.length; i++) {
		arr[i] = 1
	}

	var ii = 0;
	for (var key in num) {
		var p = num[key]
		for (var i = 0; i < p["r"]; i++) {
			var n = ii % N
			arr[n] *= p["num"]
			ii++
		}
	}

	// console.log(JSON.stringify(arr))
	console.log(gcd(arr))
	// console.log(JSON.stringify(num))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));