"use strict";
    
const getAllFactorsFor = remainder => {
    let factors = [], i;

    for (i = 2; i <= remainder; i++) {
        while ((remainder % i) === 0) {
            factors.push(i);
            remainder /= i;
        }
    }

    return factors;
}

const gcdTwoNumbers = (x, y) => {
  while(y) {
    let t = y;
    y = x % y;
    x = t;
  }
  
  return x;
}

const getGcd = input => {
    let len, a, b;
	len = input.length;
	
	a = input[ 0 ];
	
	for ( var i = 1; i < len; i++ ) {
		b = input[ i ];
		a = gcdTwoNumbers(a, b);
	}
	
	return a;
}

const combineWithoutRepetitions = (comboOptions, comboLength) => {
  if (comboLength === 1) {
    return comboOptions.map(comboOption => [comboOption]);
  }

  const combos = [];

  comboOptions.forEach((currentOption, optionIndex) => {
    const smallerCombos = combineWithoutRepetitions(
      comboOptions.slice(optionIndex + 1),
      comboLength - 1
    );

    smallerCombos.forEach((smallerCombo) => {
      combos.push([currentOption].concat(smallerCombo));
    });
  });

  return combos;
}

const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const P = parseInt(arg[0].split(" ")[1]);
    
    const factors = getAllFactorsFor(P);
    factors.unshift(1);
    factors.push(P);
    
    const combos = combineWithoutRepetitions(factors, N);
    
    let answer = 1;
    
    for(let i in combos) {
        let gcd = getGcd(combos[i]);
        
        answer = Math.max(answer, gcd);
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));